Merge branch 'master' into wind_(story53)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,11 +92,8 @@ public class HeartBeatService implements RunnableWithFramePeriod {
|
||||
|
||||
while (!Thread.interrupted()) {
|
||||
long currentFrameTime = System.currentTimeMillis();
|
||||
try {
|
||||
waitForFramePeriod(lastHeartbeatTime, currentFrameTime, heartbeatPeriod);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
waitForFramePeriod(lastHeartbeatTime, currentFrameTime, heartbeatPeriod);
|
||||
|
||||
lastHeartbeatTime = currentFrameTime;
|
||||
|
||||
try {
|
||||
|
||||
@@ -50,17 +50,9 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
public void run() {
|
||||
race.initialiseBoats();
|
||||
|
||||
try {
|
||||
countdown();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
countdown();
|
||||
|
||||
try {
|
||||
raceLoop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
raceLoop();
|
||||
}
|
||||
|
||||
public void boolFalse(){
|
||||
@@ -71,7 +63,7 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
/**
|
||||
* Countdown timer until race starts.
|
||||
*/
|
||||
private void countdown() throws Exception {
|
||||
private void countdown() {
|
||||
|
||||
long previousFrameTime = System.currentTimeMillis();
|
||||
|
||||
@@ -110,7 +102,7 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
/**
|
||||
* Timer that runs for the duration of the race, until all boats finish.
|
||||
*/
|
||||
private void raceLoop() throws Exception {
|
||||
private void raceLoop() {
|
||||
|
||||
long previousFrameTime = System.currentTimeMillis();
|
||||
|
||||
@@ -199,4 +191,4 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
// else if(e.getBearing().degrees() > 270) System.out.println("Port");
|
||||
// else System.out.println("Behind");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user