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:
@@ -44,7 +44,7 @@ public class MockOutput implements Runnable
|
|||||||
|
|
||||||
public MockOutput() throws IOException {
|
public MockOutput() throws IOException {
|
||||||
lastHeartbeatTime = System.currentTimeMillis();
|
lastHeartbeatTime = System.currentTimeMillis();
|
||||||
serverSocket = new ServerSocket(4942);
|
serverSocket = new ServerSocket(4943);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* calculates the time since last heartbeat
|
* calculates the time since last heartbeat
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Race implements Runnable {
|
|||||||
protected int boatsFinished = 0;
|
protected int boatsFinished = 0;
|
||||||
protected long totalTimeElapsed;
|
protected long totalTimeElapsed;
|
||||||
protected int scaleFactor;
|
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 countdownFinish = false;
|
||||||
protected boolean runRace = true;
|
protected boolean runRace = true;
|
||||||
private int lastFPS = 20;
|
private int lastFPS = 20;
|
||||||
@@ -66,10 +66,6 @@ public class Race implements Runnable {
|
|||||||
this(raceData.getBoats(), raceData.getLegs(), scaleFactor, mockOutput);
|
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
|
* 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 each boat, we update it's position, and generate a BoatLocationMessage.
|
||||||
for (Boat boat : startingBoats) {
|
for (Boat boat : startingBoats) {
|
||||||
if (boat != null && boat.getTimeFinished() < 0) {
|
if (boat != null) {
|
||||||
//Update position.
|
//Update position.
|
||||||
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
|
if (boat.getTimeFinished() < 0) {
|
||||||
checkPosition(boat, totalTimeElapsed);
|
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());
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude());
|
||||||
System.out.println("Sending boat status");
|
|
||||||
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
|
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
|
||||||
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
|
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ public class StartController extends Controller implements Observer {
|
|||||||
try {
|
try {
|
||||||
raceData = new StreamedCourse();
|
raceData = new StreamedCourse();
|
||||||
raceData.addObserver(this);
|
raceData.addObserver(this);
|
||||||
visualiserInput = new VisualiserInput(new Socket("livedata.americascup.com", 4941), raceData);
|
// visualiserInput = new VisualiserInput(new Socket("livedata.americascup.com", 4941), raceData);
|
||||||
|
visualiserInput = new VisualiserInput(new Socket(InetAddress.getLocalHost(), 4943), raceData);
|
||||||
new Thread(visualiserInput).start();
|
new Thread(visualiserInput).start();
|
||||||
// StreamedCourse streamedCourse = new StreamedCourse(new BoatXMLReader("mockXML/boatXML/boatTest.xml"));
|
// StreamedCourse streamedCourse = new StreamedCourse(new BoatXMLReader("mockXML/boatXML/boatTest.xml"));
|
||||||
// streamedCourse.setStreamedCourseXMLReader(new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml"));
|
// streamedCourse.setStreamedCourseXMLReader(new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml"));
|
||||||
|
|||||||
@@ -87,10 +87,13 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
|
|
||||||
raceID = Integer.parseInt(getTextValueOfNode(settings, "RaceID"));
|
raceID = Integer.parseInt(getTextValueOfNode(settings, "RaceID"));
|
||||||
raceType = getTextValueOfNode(settings, "RaceType");
|
raceType = getTextValueOfNode(settings, "RaceType");
|
||||||
creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat);
|
//creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat);
|
||||||
|
|
||||||
|
// creationTimeDate = ZonedDateTime.now();
|
||||||
|
// raceStartTime = ZonedDateTime.now();
|
||||||
if (raceTimeTag.getNamedItem("Time") != null) 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);
|
else raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Start").getTextContent(), dateFormat);
|
||||||
|
|
||||||
postpone = Boolean.parseBoolean(raceTimeTag.getNamedItem("Postpone").getTextContent());
|
postpone = Boolean.parseBoolean(raceTimeTag.getNamedItem("Postpone").getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ public class StreamedRace extends Race {
|
|||||||
boatsFinished++;
|
boatsFinished++;
|
||||||
boat.setTimeFinished(timeElapsed);
|
boat.setTimeFinished(timeElapsed);
|
||||||
boat.setFinished(true);
|
boat.setFinished(true);
|
||||||
} else {
|
|
||||||
boat.setCurrentLeg(raceData.getLegs().get(legNumber));
|
|
||||||
}
|
}
|
||||||
//Update the boat display table in the GUI to reflect the leg change
|
//Update the boat display table in the GUI to reflect the leg change
|
||||||
updatePositions();
|
updatePositions();
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public class VisualiserInput implements Runnable
|
|||||||
|
|
||||||
public static void main(String argv[]) throws Exception
|
public static void main(String argv[]) throws Exception
|
||||||
{
|
{
|
||||||
Socket socket = new Socket(InetAddress.getLocalHost(), 4942);
|
Socket socket = new Socket(InetAddress.getLocalHost(), 4943);
|
||||||
VisualiserInput receiver = new VisualiserInput(socket, new StreamedCourse());
|
VisualiserInput receiver = new VisualiserInput(socket, new StreamedCourse());
|
||||||
receiver.run();
|
receiver.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user