Added boat velocity to information provided by mock
#story[778]
This commit is contained in:
@@ -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
|
* 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){
|
public synchronized void parseBoatLocation(int sourceID, double lat, double lon, double heading, double speed){
|
||||||
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading);
|
|
||||||
|
int newSpeed = (int) Math.round((speed * Constants.KnotsToMetersPerSecondConversionFactor * 1000));
|
||||||
|
|
||||||
|
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceID, lat, lon, boatLocationSequenceNumber, heading, newSpeed);
|
||||||
//iterates the sequence number
|
//iterates the sequence number
|
||||||
boatLocationSequenceNumber++;
|
boatLocationSequenceNumber++;
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class Race implements Runnable {
|
|||||||
for (int i = 0; i < startingBoats.size(); i++) {
|
for (int i = 0; i < startingBoats.size(); i++) {
|
||||||
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
|
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
|
||||||
if (boat != null) {
|
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(),
|
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()));
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,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(), boat.getHeading());
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getScaledVelocity());
|
||||||
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, double heading) {
|
public BoatLocationMessage(int sourceID, double lat, double lon, long sequenceNumber, double heading, int boatSpeed) {
|
||||||
super(MessageType.BOATLOCATION);
|
super(MessageType.BOATLOCATION);
|
||||||
|
|
||||||
this.messageVersionNumber = (byte) 1;
|
this.messageVersionNumber = (byte) 1;
|
||||||
@@ -164,7 +164,7 @@ public class BoatLocationMessage extends AC35Data
|
|||||||
this.heading = convertHeadingDoubleToInt(heading);
|
this.heading = convertHeadingDoubleToInt(heading);
|
||||||
this.pitch = 0;
|
this.pitch = 0;
|
||||||
this.roll = 0;
|
this.roll = 0;
|
||||||
this.boatSpeed = 0;
|
this.boatSpeed = boatSpeed;
|
||||||
this.boatCOG = 0;
|
this.boatCOG = 0;
|
||||||
this.boatSOG = 0;
|
this.boatSOG = 0;
|
||||||
this.apparentWindSpeed = 0;
|
this.apparentWindSpeed = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user