-refactered decoders into own package -added race status decoder -added race start status decoder -started on the boat location decoder #story[778, 782]main
parent
ee24ecaadc
commit
ec0747ab9a
@ -0,0 +1,28 @@
|
||||
package seng302.Networking.MessageDecoders;
|
||||
|
||||
/**
|
||||
* Created by hba56 on 21/04/17.
|
||||
*/
|
||||
public class BoatLocationDecoder {
|
||||
int messageVersionNumber;
|
||||
byte[] time;
|
||||
byte[] sourceID;
|
||||
byte[] seqNum;
|
||||
byte[] deviceType;
|
||||
byte[] latitude;
|
||||
byte[] longitude;
|
||||
byte[] altitude;
|
||||
byte[] heading;
|
||||
byte[] pitch;
|
||||
byte[] roll;
|
||||
byte[] boatSpeed;
|
||||
byte[] cog;
|
||||
byte[] sog;
|
||||
byte[] apparentWindSpeed;
|
||||
byte[] apparentWindAngle;
|
||||
byte[] trueWindSpeed;
|
||||
byte[] trueWindAngle;
|
||||
byte[] currentDrift;
|
||||
byte[] currentSet;
|
||||
byte[] rudderAngle;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package seng302.Networking.MessageDecoders;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by hba56 on 21/04/17.
|
||||
*/
|
||||
public class RaceStartStatus {
|
||||
byte messageVersion;
|
||||
byte[] timestamp;
|
||||
byte[] ackNumber;
|
||||
byte[] raceStartTime;
|
||||
byte[] raceIdentifier;
|
||||
byte notificationType;
|
||||
|
||||
public RaceStartStatus(byte[] encodedRaceStartStatus) {
|
||||
messageVersion = encodedRaceStartStatus[0];
|
||||
timestamp = Arrays.copyOfRange(encodedRaceStartStatus, 1, 7);
|
||||
ackNumber = Arrays.copyOfRange(encodedRaceStartStatus, 7, 9);
|
||||
raceStartTime = Arrays.copyOfRange(encodedRaceStartStatus, 9, 15);
|
||||
raceIdentifier = Arrays.copyOfRange(encodedRaceStartStatus, 15, 19);
|
||||
notificationType = encodedRaceStartStatus[19];
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package seng302.Networking.MessageDecoders;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by hba56 on 21/04/17.
|
||||
*/
|
||||
public class RaceStatusDecoder {
|
||||
byte versionNum;
|
||||
byte[] timeBytes;
|
||||
byte[] raceID;
|
||||
byte raceStatus;
|
||||
byte[] expectedStart;
|
||||
byte[] raceWind;
|
||||
byte[] windSpeed;
|
||||
byte numBoats;
|
||||
byte[] bytesRaceType;
|
||||
|
||||
public RaceStatusDecoder(byte[] encodedRaceStatus){
|
||||
versionNum = encodedRaceStatus[0];
|
||||
timeBytes = Arrays.copyOfRange(encodedRaceStatus, 1, 7);
|
||||
raceID = Arrays.copyOfRange(encodedRaceStatus, 7, 11);
|
||||
raceStatus = encodedRaceStatus[12];
|
||||
expectedStart = Arrays.copyOfRange(encodedRaceStatus, 13, 19);
|
||||
raceWind = Arrays.copyOfRange(encodedRaceStatus, 19, 21);
|
||||
windSpeed = Arrays.copyOfRange(encodedRaceStatus, 21, 23);
|
||||
numBoats = encodedRaceStatus[23];
|
||||
bytesRaceType = Arrays.copyOfRange(encodedRaceStatus, 24, 24+20*this.numBoats);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package seng302.Networking;
|
||||
package seng302.Networking.MessageDecoders;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
Loading…
Reference in new issue