Merge branch 'networkingTest' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into networkingTest
This commit is contained in:
@@ -28,7 +28,7 @@ public class RaceStatusDecoder {
|
||||
private int race;
|
||||
private int raceState;
|
||||
private long startTime;
|
||||
private short raceWindDir;
|
||||
private int raceWindDir;
|
||||
private short raceWindSpeed;
|
||||
private int numberOfBoats;
|
||||
private int raceType;
|
||||
@@ -51,7 +51,7 @@ public class RaceStatusDecoder {
|
||||
race = bytesToInt(raceID);
|
||||
raceState = bytesToInt(raceStatus);
|
||||
startTime = bytesToLong(expectedStart);
|
||||
raceWindDir = bytesToShort(raceWind);
|
||||
raceWindDir = bytesToInt(raceWind);
|
||||
raceWindSpeed = bytesToShort(windSpeed);
|
||||
numberOfBoats = bytesToInt(numBoats);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RaceStatusDecoder {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public short getRaceWindDir() {
|
||||
public int getRaceWindDir() {
|
||||
return raceWindDir;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RaceVisionByteEncoder {
|
||||
|
||||
public byte[] heartBeat(int seq){
|
||||
ByteBuffer heartBeat = ByteBuffer.allocate(4);
|
||||
heartBeat.putInt(seq);
|
||||
heartBeat.put(intToBytes(seq));
|
||||
byte [] result = heartBeat.array();
|
||||
return result;
|
||||
}
|
||||
@@ -29,11 +29,11 @@ public class RaceVisionByteEncoder {
|
||||
//Version Number 1 bytes
|
||||
byte versionNum = 0b10; //this changes with the pdf. (2)
|
||||
byte[] timeBytes = longToBytes(time, 6);//time (6 bytes)
|
||||
byte[] raceID = ByteBuffer.allocate(4).putInt(race).array();//race identifier incase multiple races are going at once.
|
||||
byte[] raceID = ByteBuffer.allocate(4).put(intToBytes(race)).array();//race identifier incase multiple races are going at once.
|
||||
byte[] raceStatus = intToBytes(raceState, 1);//race status 0 - 10
|
||||
byte[] expectedStart = longToBytes(startTime, 6);//number of milliseconds from Jan 1, 1970 for when the data is valid
|
||||
byte[] raceWind = ByteBuffer.allocate(2).putShort(raceWindDir).array();//North = 0x0000 East = 0x4000 South = 0x8000
|
||||
byte[] windSpeed = ByteBuffer.allocate(2).putShort(raceWindSpeed).array();//mm/sec
|
||||
byte[] raceWind = ByteBuffer.allocate(2).put(shortToBytes(raceWindDir)).array();//North = 0x0000 East = 0x4000 South = 0x8000
|
||||
byte[] windSpeed = ByteBuffer.allocate(2).put(shortToBytes(raceWindSpeed)).array();//mm/sec
|
||||
byte[] numBoats = intToBytes(boats.size(), 1);
|
||||
byte[] bytesRaceType = intToBytes(raceType, 1);//1 match race, 2 fleet race
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RaceVisionByteEncoder {
|
||||
byte[] estNextMarkTime = longToBytes((long)0, 6);//TODO use boats estimated time to next mark.
|
||||
byte[] estFinishTime = longToBytes((long) 0, 6);//TODO use boats estimated time to the finish.
|
||||
|
||||
raceStatusMessage.putInt(sourceID);
|
||||
raceStatusMessage.put(intToBytes(sourceID));
|
||||
raceStatusMessage.put(legNum);
|
||||
raceStatusMessage.put(numPenalties);
|
||||
raceStatusMessage.put(numPenaltiesServed);
|
||||
@@ -120,7 +120,7 @@ public class RaceVisionByteEncoder {
|
||||
result.put(timestamp);
|
||||
result.put(ackNumber);
|
||||
result.put(raceStartTime);
|
||||
result.putInt(raceIdentifier);
|
||||
result.put(intToBytes(raceIdentifier));
|
||||
result.put(notificationType);
|
||||
|
||||
return result.array();
|
||||
@@ -140,9 +140,9 @@ public class RaceVisionByteEncoder {
|
||||
result.put(intToBytes(messageVersion, 1));
|
||||
result.put(encodeTime);
|
||||
result.putShort(ackNum);
|
||||
result.putInt(raceUID);
|
||||
result.putInt(destSource);
|
||||
result.putInt(incident);
|
||||
result.put(intToBytes(raceUID));
|
||||
result.put(intToBytes(destSource));
|
||||
result.put(intToBytes(incident));
|
||||
result.put(event);
|
||||
return result.array();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RaceStatusDecoderTest {
|
||||
Assert.assertEquals(1, decoderTest.getRace());
|
||||
Assert.assertEquals(2, decoderTest.getRaceState());
|
||||
Assert.assertEquals(time2, decoderTest.getStartTime());
|
||||
Assert.assertEquals((short)2, decoderTest.getRaceWindDir());
|
||||
Assert.assertEquals(2, decoderTest.getRaceWindDir());
|
||||
Assert.assertEquals((short)3, decoderTest.getRaceWindSpeed());
|
||||
|
||||
Assert.assertEquals(0, decoderTest.getBoats().get(0).getBoatStatus());
|
||||
|
||||
Reference in New Issue
Block a user