Merge branch 'master' into wind_(story53)

This commit is contained in:
Joseph Gardner
2017-08-29 13:22:15 +12:00
50 changed files with 157 additions and 2047 deletions
@@ -85,22 +85,15 @@ public class Event {
//Read XML files.
try {
this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
} catch (XMLReaderException e) {
throw new EventConstructionException("Could not read XML files.", e);
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (InvalidRaceDataException e) {
e.printStackTrace();
} catch (JAXBException e) {
e.printStackTrace();
}
this.xmlFileType = XMLFileType.Contents;
@@ -177,13 +170,6 @@ public class Event {
/**
* Sends the initial race data and then begins race simulation.
*/
public void start() {
}
/**
* Sends out each xml string, via the mock output
@@ -196,4 +182,29 @@ public class Event {
connectionAcceptor.setBoatsXml(boatXML);
}
}
//TODO remove this after demo on 18th august!
/**
* Sets the xml description of the race to show the race was created now, and starts in 4 minutes
* @param raceXML The race.xml contents.
* @return String containing edited xml
*/
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
long millisecondsToAdd = Constants.RacePreStartTime + (1 * 60 * 1000);
long secondsToAdd = millisecondsToAdd / 1000;
//Scale the time using our time scalar.
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
ZonedDateTime creationTime = ZonedDateTime.now();
raceXML = raceXML.replace("RACE_CREATION_TIME", dateFormat.format(creationTime));
raceXML = raceXML.replace("RACE_START_TIME", dateFormat.format(creationTime.plusSeconds(secondsToAdd)));
return raceXML;
}
}
@@ -101,8 +101,6 @@ public class MockOutput implements RunnableWithFramePeriod {
Logger.getGlobal().log(Level.WARNING, "MockOutput.run() interrupted while putting message in queue.", e);
Thread.currentThread().interrupt();
return;
} catch (Exception e) {
e.printStackTrace();
}
}