Added heading to boatlocation messages

#story[778]
main
Erika Savell 9 years ago
parent f2e0eec212
commit 42ad1f78fc

@ -235,7 +235,6 @@ public class RaceData {
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME; DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"); dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
String text = dateFormat.format(time); String text = dateFormat.format(time);
System.out.println(text);
return text; return text;

@ -86,8 +86,8 @@ public class MockOutput implements Runnable
/** /**
* Used to give the mocOutput information about boat location to be made into a message and sent * Used to give the mocOutput information about boat location to be made into a message and sent
*/ */
public synchronized void parseBoatLocation(int sourceID, double lat, double lon){ public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading){
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber); BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading);
//iterates the sequence number //iterates the sequence number
boatLocationSequenceNumber++; boatLocationSequenceNumber++;

@ -62,7 +62,6 @@ public class Event {
RaceData raceData = new RaceData(raceDataSource); RaceData raceData = new RaceData(raceDataSource);
//Serialize race data to an XML as a string. //Serialize race data to an XML as a string.
String xmlString = raceData.createXML(); String xmlString = raceData.createXML();
System.out.println(xmlString);
mockOutput.setRaceXml(xmlString); mockOutput.setRaceXml(xmlString);
mockOutput.parseXMLString(xmlString, 26); mockOutput.parseXMLString(xmlString, 26);
} }
@ -71,7 +70,6 @@ public class Event {
BoatData boatData = new BoatData(raceDataSource.getBoats()); BoatData boatData = new BoatData(raceDataSource.getBoats());
//Serialize race data to an XML as a string. //Serialize race data to an XML as a string.
String xmlString = boatData.createXML(); String xmlString = boatData.createXML();
System.out.println(xmlString);
mockOutput.setBoatsXml(xmlString); mockOutput.setBoatsXml(xmlString);
mockOutput.parseXMLString(xmlString, 26); mockOutput.parseXMLString(xmlString, 26);

@ -95,8 +95,6 @@ public class Race implements Runnable {
*/ */
public void run() { public void run() {
initialiseBoats(); initialiseBoats();
System.out.println("Beginning");
countdownTimer(); countdownTimer();
} }
@ -119,7 +117,6 @@ public class Race implements Runnable {
@Override @Override
public void handle(long arg0) { public void handle(long arg0) {
timeLeft = startTime - currentTime; timeLeft = startTime - currentTime;
System.out.println(timeLeft);
if (timeLeft <= 0) { if (timeLeft <= 0) {
countdownFinish = true; countdownFinish = true;
stop(); stop();
@ -146,7 +143,6 @@ public class Race implements Runnable {
*/ */
private void simulateRace() { private void simulateRace() {
System.out.println("Running");
System.setProperty("javafx.animation.fullspeed", "true"); System.setProperty("javafx.animation.fullspeed", "true");
for (Boat boat : startingBoats) { for (Boat boat : startingBoats) {
@ -174,7 +170,7 @@ public class Race implements Runnable {
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS)); updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
checkPosition(boat, totalTimeElapsed); checkPosition(boat, totalTimeElapsed);
} }
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude()); mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading());
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 {

@ -150,7 +150,7 @@ public class BoatLocationMessage extends AC35Data
this.rudderAngle = rudderAngle; this.rudderAngle = rudderAngle;
} }
public BoatLocationMessage(int sourceID, double lat, double lon, long sequenceNumber) { public BoatLocationMessage(int sourceID, double lat, double lon, long sequenceNumber, double heading) {
super(MessageType.BOATLOCATION); super(MessageType.BOATLOCATION);
this.messageVersionNumber = (byte) 1; this.messageVersionNumber = (byte) 1;
@ -161,7 +161,7 @@ public class BoatLocationMessage extends AC35Data
this.latitude = convertGPSToInt(lat); this.latitude = convertGPSToInt(lat);
this.longitude = convertGPSToInt(lon); this.longitude = convertGPSToInt(lon);
this.altitude = 0; this.altitude = 0;
this.heading = 0; this.heading = convertHeadingDoubleToInt(heading);
this.pitch = 0; this.pitch = 0;
this.roll = 0; this.roll = 0;
this.boatSpeed = 0; this.boatSpeed = 0;

@ -62,7 +62,7 @@ public class BinaryMessageDecoderTest {
// Assert.assertEquals(xmlString.toString(), contents); // Assert.assertEquals(xmlString.toString(), contents);
}catch (IOException e){ }catch (IOException e){
System.out.println(e); e.printStackTrace();
} }
} }
} }

@ -41,7 +41,7 @@ public class XMLMessageDecoderTest {
Assert.assertEquals((short)xmlString.length(), decoderXML.getXmlMsgLength()); Assert.assertEquals((short)xmlString.length(), decoderXML.getXmlMsgLength());
}catch (IOException e){ }catch (IOException e){
System.out.println(e); e.printStackTrace();
} }
} }
} }

@ -28,7 +28,7 @@ public class XMLMessageEncoderTest {
//1 + 2 + 6 + 1 + 2 + 2 + 374 //1 + 2 + 6 + 1 + 2 + 2 + 374
Assert.assertEquals(388, encodedXML.length); Assert.assertEquals(388, encodedXML.length);
}catch (IOException e){ }catch (IOException e){
System.out.println(e); e.printStackTrace();
} }
} }
@ -49,7 +49,7 @@ public class XMLMessageEncoderTest {
Assert.assertEquals(null, encodedXML); Assert.assertEquals(null, encodedXML);
}catch (IOException e){ }catch (IOException e){
System.out.println(e); e.printStackTrace();
} }
} }
} }

@ -29,7 +29,6 @@ public class StreamedCourse extends Observable implements RaceDataSource {
this.boatXMLReader = boatXMLReader; this.boatXMLReader = boatXMLReader;
if (streamedCourseXMLReader != null && boatXMLReader != null) { if (streamedCourseXMLReader != null && boatXMLReader != null) {
boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants()); boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants());
System.out.println("Participant size: " + streamedCourseXMLReader.getParticipants().size());
boatXMLReader.read(); boatXMLReader.read();
} }

@ -89,7 +89,6 @@ public class StreamedCourseXMLReader extends XMLReader {
raceType = getTextValueOfNode(settings, "RaceType"); raceType = getTextValueOfNode(settings, "RaceType");
creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat); creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat);
// System.out.println(getTextValueOfNode(settings, "CreationTimeDate"));
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);

@ -87,7 +87,6 @@ public class StreamedRace extends Race {
int sourceID = boat.getSourceID(); int sourceID = boat.getSourceID();
BoatLocationMessage boatLocationMessage = visualiserInput.getBoatLocationMessage(sourceID); BoatLocationMessage boatLocationMessage = visualiserInput.getBoatLocationMessage(sourceID);
if(boatLocationMessage != null) { if(boatLocationMessage != null) {
System.out.println(sourceID);
double lat = boatLocationMessage.getLatitudeDouble(); double lat = boatLocationMessage.getLatitudeDouble();
double lon = boatLocationMessage.getLongitudeDouble(); double lon = boatLocationMessage.getLongitudeDouble();
boat.setCurrentPosition(new GPSCoordinate(lat, lon)); boat.setCurrentPosition(new GPSCoordinate(lat, lon));

Loading…
Cancel
Save