Merge remote-tracking branch 'origin/splitIntoTwoModules' into splitIntoTwoModules
# Conflicts: # visualiser/src/main/java/seng302/VisualiserInput.java
This commit is contained in:
@@ -193,8 +193,12 @@ public class StartController extends Controller implements Observer {
|
||||
if(((StreamedCourse) o).getBoats() != null) {
|
||||
initialiseTables();
|
||||
}
|
||||
if(((StreamedCourse)o).getZonedDateTime() != null) {
|
||||
setRaceClock();
|
||||
if (((StreamedCourse) o).getZonedDateTime() != null) {
|
||||
Platform.runLater(() -> {
|
||||
{
|
||||
setRaceClock();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package seng302.Mock;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import org.joda.time.DateTime;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
@@ -71,25 +72,28 @@ public class StreamedCourseXMLReader extends XMLReader {
|
||||
}
|
||||
|
||||
private void read() throws ParseException, StreamedCourseXMLException {
|
||||
// readRace();
|
||||
readRace();
|
||||
readParticipants();
|
||||
readCourse();
|
||||
}
|
||||
|
||||
private void readRace() throws ParseException {
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
Element settings = (Element) doc.getElementsByTagName("Race").item(0);
|
||||
|
||||
System.out.println(getTextValueOfNode(settings, "CreationTimeDate"));
|
||||
raceID = Integer.parseInt(getTextValueOfNode(settings, "RaceID"));
|
||||
raceType = getTextValueOfNode(settings, "RaceType");
|
||||
creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat);
|
||||
NamedNodeMap raceTimeTag = doc.getElementsByTagName("RaceStartTime").item(0).getAttributes();
|
||||
raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Time").getTextContent(), dateFormat);
|
||||
if (raceTimeTag.getNamedItem("Time") != null) raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Time").getTextContent(), dateFormat);
|
||||
else raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Start").getTextContent(), dateFormat);
|
||||
postpone = Boolean.parseBoolean(raceTimeTag.getNamedItem("Postpone").getTextContent());
|
||||
}
|
||||
|
||||
private void readParticipants() {
|
||||
Element nParticipants = (Element) doc.getElementsByTagName("Participants").item(0);
|
||||
nParticipants.getChildNodes().getLength();
|
||||
for (int i = 0; i < nParticipants.getChildNodes().getLength(); i++) {
|
||||
int sourceID;
|
||||
Node yacht = nParticipants.getChildNodes().item(i);
|
||||
@@ -157,7 +161,8 @@ public class StreamedCourseXMLReader extends XMLReader {
|
||||
* @return value of "compoundMarkID" attribute
|
||||
*/
|
||||
private int getCompoundMarkID(Element element) {
|
||||
return Integer.parseInt(element.getAttribute("CompoundMarkID"));
|
||||
//return Integer.parseInt(element.getAttribute("CompoundMarkID"));
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,11 @@ public class VisualiserInput implements Runnable
|
||||
|
||||
private Map<Integer, BoatLocationMessage> boatLocation;
|
||||
|
||||
private RaceStatus raceStatus;
|
||||
|
||||
private Map<Integer, BoatStatusMessage> boatStatus;
|
||||
|
||||
public VisualiserInput(StreamedCourse course) throws IOException{
|
||||
public VisualiserInput(Socket socket, StreamedCourse course) throws IOException{
|
||||
|
||||
this.connectionSocket = socket;
|
||||
@@ -44,6 +49,7 @@ public class VisualiserInput implements Runnable
|
||||
|
||||
this.course = course;
|
||||
this.boatLocation = new HashMap<>();
|
||||
this.boatStatus = new HashMap<>();
|
||||
|
||||
|
||||
//start Time
|
||||
@@ -77,6 +83,30 @@ public class VisualiserInput implements Runnable
|
||||
return (now - lastHeartbeatTime) / 1000.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boat locations
|
||||
* @return locations of where the boats are
|
||||
*/
|
||||
public Map<Integer, BoatLocationMessage> getBoatLocation() {
|
||||
return boatLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status of the race
|
||||
* @return the status of the race
|
||||
*/
|
||||
public RaceStatus getRaceStatus() {
|
||||
return raceStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashmap of the boat status'
|
||||
* @return Hash map of boat status
|
||||
*/
|
||||
public Map<Integer, BoatStatusMessage> getBoatStatus() {
|
||||
return boatStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -128,14 +158,18 @@ public class VisualiserInput implements Runnable
|
||||
// System.out.println("HeartBeat Message! " + heartbeatSeqNum);
|
||||
break;
|
||||
case RACESTATUS:
|
||||
// System.out.println("Race Status Message");
|
||||
System.out.println("Race Status Message");
|
||||
raceStatus = ((RaceStatus) data);
|
||||
for (BoatStatusMessage msg: raceStatus.getBoatStatusMessages()){
|
||||
boatStatus.put(msg.getSourceID(), msg);
|
||||
}
|
||||
break;
|
||||
case DISPLAYTEXTMESSAGE:
|
||||
// System.out.println("Display Text Message");
|
||||
//no decoder for this.
|
||||
break;
|
||||
case XMLMESSAGE:
|
||||
// System.out.println("XML Message!");
|
||||
System.out.println("XML Message!");
|
||||
XMLMessage xml = (XMLMessage) data;
|
||||
try {
|
||||
if (xml.getXmlMsgSubType() == xml.XMLTypeRegatta){
|
||||
@@ -159,7 +193,7 @@ public class VisualiserInput implements Runnable
|
||||
}
|
||||
break;
|
||||
case RACESTARTSTATUS:
|
||||
System.out.println("Race Start Status Message");
|
||||
//System.out.println("Race Start Status Message");
|
||||
break;
|
||||
case YACHTEVENTCODE:
|
||||
// System.out.println("Yacht Action Code!");
|
||||
|
||||
Reference in New Issue
Block a user