Added a dynamically updating course limits file to the model.

This will make manual testing of the course limits easier. When the race starts, the limits encapsulate the start line but soon after the race starts the course limits close off around the start line (this is for the model). This means the model acts in a very similar way to the actual live stream.

#story[889]
This commit is contained in:
Kusal Ekanayake
2017-05-15 17:09:12 +12:00
parent 94d1982670
commit 110143ae6e
5 changed files with 138 additions and 9 deletions
+24 -2
View File
@@ -235,6 +235,27 @@ public class ServerThread implements Runnable, Observer {
}
}
/**
* Send the post-start race course information
*/
private void sendPostStartCourseXml(){
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
try {
Message raceData = getXmlMessage("/server_config/courseLimits.xml", XMLMessageSubType.RACE);
if (raceData != null) {
server.send(raceData);
serverLog("Sending race data", 0);
}
}catch (IOException e) {
serverLog("Couldn't send an XML Message: " + e.getMessage(), 0);
}
}
},25000);
}
public void run() {
try{
server = new StreamingServerSocket(PORT_NUMBER);
@@ -252,12 +273,13 @@ public class ServerThread implements Runnable, Observer {
sendXml();
startSendingRaceStartStatusMessages();
startSendingRaceStatusMessages();
sendPostStartCourseXml();
}
/**
* Start sending static boat position updates when race has finished
*/
private void startSendingRaceFinishedBoatPostions(){
private void startSendingRaceFinishedBoatPositions(){
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
@@ -316,7 +338,7 @@ public class ServerThread implements Runnable, Observer {
}
if (numOfBoatsFinished == ((List<Boat>) arg).size()) {
startSendingRaceFinishedBoatPostions();
startSendingRaceFinishedBoatPositions();
}
}