Added boat velocity to information provided by mock

#story[778]
main
Erika Savell 9 years ago
parent 5a92dd68f5
commit d2e08fa8e1

@ -86,8 +86,11 @@ 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, double heading){
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading);
public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed){
int newSpeed = (int) Math.round((speed * Constants.KnotsToMetersPerSecondConversionFactor * 1000));
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading, newSpeed);
//iterates the sequence number
boatLocationSequenceNumber++;

@ -125,7 +125,7 @@ public class Race implements Runnable {
for (int i = 0; i < startingBoats.size(); i++) {
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
if (boat != null) {
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading());
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getScaledVelocity());
boatStatusMessages.add(new BoatStatusMessage(boat.getSourceID(),
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatus.RACING : BoatStatus.DNF, boat.getCurrentLeg().getLegNumber()));
}
@ -194,7 +194,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(), boat.getHeading());
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getScaledVelocity());
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, double heading) {
public BoatLocationMessage(int sourceID, double lat, double lon, long sequenceNumber, double heading, int boatSpeed) {
super(MessageType.BOATLOCATION);
this.messageVersionNumber = (byte) 1;
@ -164,7 +164,7 @@ public class BoatLocationMessage extends AC35Data
this.heading = convertHeadingDoubleToInt(heading);
this.pitch = 0;
this.roll = 0;
this.boatSpeed = 0;
this.boatSpeed = boatSpeed;
this.boatCOG = 0;
this.boatSOG = 0;
this.apparentWindSpeed = 0;

Loading…
Cancel
Save