Got mock data being used by visualiser.

- Issue with zonedTimeDate not parsing
- Fixed race crashing once one boat finished

#story[778]
This commit is contained in:
Erika Savell
2017-05-01 20:56:46 +12:00
parent d1baf021ac
commit 7d1f4209e4
6 changed files with 14 additions and 15 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ public class MockOutput implements Runnable
public MockOutput() throws IOException {
lastHeartbeatTime = System.currentTimeMillis();
serverSocket = new ServerSocket(4942);
serverSocket = new ServerSocket(4943);
}
/**
* calculates the time since last heartbeat
+6 -9
View File
@@ -31,7 +31,7 @@ public class Race implements Runnable {
protected int boatsFinished = 0;
protected long totalTimeElapsed;
protected int scaleFactor;
protected int PRERACE_TIME = 12; //time in milliseconds to pause during pre-race
protected int PRERACE_TIME = 12000; //time in milliseconds to pause during pre-race
protected boolean countdownFinish = false;
protected boolean runRace = true;
private int lastFPS = 20;
@@ -66,10 +66,6 @@ public class Race implements Runnable {
this(raceData.getBoats(), raceData.getLegs(), scaleFactor, mockOutput);
}
public void setRaceId(int raceId) {
this.raceId = raceId;
}
/**
* Calculates the boats next GPS position based on its distance travelled and heading
*
@@ -172,12 +168,13 @@ public class Race implements Runnable {
//For each boat, we update it's position, and generate a BoatLocationMessage.
for (Boat boat : startingBoats) {
if (boat != null && boat.getTimeFinished() < 0) {
if (boat != null) {
//Update position.
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
checkPosition(boat, totalTimeElapsed);
if (boat.getTimeFinished() < 0) {
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
checkPosition(boat, totalTimeElapsed);
}
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude());
System.out.println("Sending boat status");
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
} else {