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;
dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
String text = dateFormat.format(time);
System.out.println(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
*/
public synchronized void parseBoatLocation(int sourceID, double lat, double lon){
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber);
public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading){
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading);
//iterates the sequence number
boatLocationSequenceNumber++;

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

@ -95,8 +95,6 @@ public class Race implements Runnable {
*/
public void run() {
initialiseBoats();
System.out.println("Beginning");
countdownTimer();
}
@ -119,7 +117,6 @@ public class Race implements Runnable {
@Override
public void handle(long arg0) {
timeLeft = startTime - currentTime;
System.out.println(timeLeft);
if (timeLeft <= 0) {
countdownFinish = true;
stop();
@ -146,7 +143,6 @@ public class Race implements Runnable {
*/
private void simulateRace() {
System.out.println("Running");
System.setProperty("javafx.animation.fullspeed", "true");
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));
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(),
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
} else {

@ -150,7 +150,7 @@ public class BoatLocationMessage extends AC35Data
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);
this.messageVersionNumber = (byte) 1;
@ -161,7 +161,7 @@ public class BoatLocationMessage extends AC35Data
this.latitude = convertGPSToInt(lat);
this.longitude = convertGPSToInt(lon);
this.altitude = 0;
this.heading = 0;
this.heading = convertHeadingDoubleToInt(heading);
this.pitch = 0;
this.roll = 0;
this.boatSpeed = 0;

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

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

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

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

@ -89,7 +89,6 @@ public class StreamedCourseXMLReader extends XMLReader {
raceType = getTextValueOfNode(settings, "RaceType");
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);
else raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Start").getTextContent(), dateFormat);

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

Loading…
Cancel
Save