From 421663c14574df1ddcb96be63f1351a4e4c9b913 Mon Sep 17 00:00:00 2001 From: fjc40 Date: Fri, 21 Apr 2017 12:54:48 +1200 Subject: [PATCH 1/3] Added device type enumerations as static ints for BoatLocationMessage. #story[778] --- .../BoatLocationMessage.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java index 1171fd6b..b5e6ca10 100644 --- a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java +++ b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java @@ -23,6 +23,21 @@ public class BoatLocationMessage ///Device type of the message (physical source of the message). private byte deviceType; + public static final int Unknown = 0; + public static final int RacingYacht = 1; + public static final int CommitteeBoat = 2; + public static final int Mark = 3; + public static final int Pin = 4; + public static final int ChaseBoat = 5; + public static final int MedicalBoat = 6; + public static final int MarshallBoat = 7; + public static final int UmpireBoat = 8; + public static final int UmpireSoftwareApplication = 9; + public static final int PrincipalRaceOfficerApplication = 10; + public static final int WeatherStation = 11; + public static final int Helicopter = 12; + public static final int DataProcessingApplication = 13; + ///Latitude of the boat. private int latitude; @@ -74,7 +89,7 @@ public class BoatLocationMessage /** - * Ctor. + * Ctor. Default. */ public BoatLocationMessage() { @@ -132,7 +147,7 @@ public class BoatLocationMessage //Getters and setters for message properties. - + public byte getMessageVersionNumber() { return messageVersionNumber; From ef53dee7fe882f30ea3565b7b4e8653d45e33b88 Mon Sep 17 00:00:00 2001 From: fjc40 Date: Fri, 21 Apr 2017 12:56:00 +1200 Subject: [PATCH 2/3] Changed device type constants to bytes. #fix #story[778] --- .../BoatLocationMessage.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java index b5e6ca10..d5f1988a 100644 --- a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java +++ b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java @@ -23,20 +23,20 @@ public class BoatLocationMessage ///Device type of the message (physical source of the message). private byte deviceType; - public static final int Unknown = 0; - public static final int RacingYacht = 1; - public static final int CommitteeBoat = 2; - public static final int Mark = 3; - public static final int Pin = 4; - public static final int ChaseBoat = 5; - public static final int MedicalBoat = 6; - public static final int MarshallBoat = 7; - public static final int UmpireBoat = 8; - public static final int UmpireSoftwareApplication = 9; - public static final int PrincipalRaceOfficerApplication = 10; - public static final int WeatherStation = 11; - public static final int Helicopter = 12; - public static final int DataProcessingApplication = 13; + public static final byte Unknown = 0; + public static final byte RacingYacht = 1; + public static final byte CommitteeBoat = 2; + public static final byte Mark = 3; + public static final byte Pin = 4; + public static final byte ChaseBoat = 5; + public static final byte MedicalBoat = 6; + public static final byte MarshallBoat = 7; + public static final byte UmpireBoat = 8; + public static final byte UmpireSoftwareApplication = 9; + public static final byte PrincipalRaceOfficerApplication = 10; + public static final byte WeatherStation = 11; + public static final byte Helicopter = 12; + public static final byte DataProcessingApplication = 13; ///Latitude of the boat. From 9e1b3365bf49479ce40d9753884c5d22da49f8e5 Mon Sep 17 00:00:00 2001 From: fjc40 Date: Fri, 21 Apr 2017 13:19:49 +1200 Subject: [PATCH 3/3] Added helper functions to BoatLocationMessage which convert between the datatypes used by the message and datatypes used by our model. (Converts boat heading, wind angle, gps coordinate). #story[778] --- .../BoatLocationMessage.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java index d5f1988a..9bacd840 100644 --- a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java +++ b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java @@ -357,4 +357,89 @@ public class BoatLocationMessage { this.rudderAngle = rudderAngle; } + + /** + * Converts a double representing a latitude or longitude coordinate to an int, as required by the streaming spec format. + * @param coordinate Latitude or longitude to convert. Double. + * @return int representation of coordinate. + */ + public static int convertCoordinateDoubleToInt(double coordinate) + { + int coordinateInt = (int) ((coordinate / 180.0) * 2147483648.0); + + return coordinateInt; + + + } + + + /** + * Converts an int representing a latitude or longitude coordinate to a double, as required by the streaming spec format. + * @param coordinate Latitude or longitude to convert. int. + * @return double representation of coordinate. + */ + public static double convertCoordinateIntToDouble(int coordinate) + { + double coordinateDouble = (double) ((coordinate * 180.0) / 2147483648.0); + + return coordinateDouble; + } + + + /** + * Converts an int representing a heading to a double, as required by the streaming spec format. + * @param heading Heading to convert. int. + * @return double representation of heading. + */ + public static double convertHeadingIntToDouble(int heading) + { + + double headingDouble = (double) ((heading * 360.0) / 65536.0); + + return headingDouble; + } + + + /** + * Converts a double representing a heading to an int, as required by the streaming spec format. + * @param heading Heading to convert. double. + * @return int representation of heading. + */ + public static int convertHeadingDoubleToInt(double heading) + { + + int headingInt = (int) ((heading / 360.0) * 65536.0); + + return headingInt; + } + + + + /** + * Converts a short representing the wind's true angle to a double, as required by the streaming spec format. + * @param angle Angle to convert. short. + * @return double representation of heading. + */ + public static double convertTrueWindAngleShortToDouble(short angle) + { + + double angleDouble = (double) ((angle * 180.0) / 32768.0); + + return angleDouble; + } + + + /** + * Converts a double representing the wind's true angle to a short, as required by the streaming spec format. + * @param angle Angle to convert. double. + * @return short representation of heading. + */ + public static short convertTrueWindAngleShortToDouble(double angle) + { + + short angleShort = (short) ((angle / 180.0) * 32768.0); + + return angleShort; + } + }