|
|
|
@ -19,7 +19,7 @@ public class RaceVisionByteEncoder {
|
|
|
|
|
|
|
|
|
|
|
|
public byte[] heartBeat(int seq){
|
|
|
|
public byte[] heartBeat(int seq){
|
|
|
|
ByteBuffer heartBeat = ByteBuffer.allocate(4);
|
|
|
|
ByteBuffer heartBeat = ByteBuffer.allocate(4);
|
|
|
|
heartBeat.putInt(seq);
|
|
|
|
heartBeat.put(intToBytes(seq));
|
|
|
|
byte [] result = heartBeat.array();
|
|
|
|
byte [] result = heartBeat.array();
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -29,11 +29,11 @@ public class RaceVisionByteEncoder {
|
|
|
|
//Version Number 1 bytes
|
|
|
|
//Version Number 1 bytes
|
|
|
|
byte versionNum = 0b10; //this changes with the pdf. (2)
|
|
|
|
byte versionNum = 0b10; //this changes with the pdf. (2)
|
|
|
|
byte[] timeBytes = longToBytes(time, 6);//time (6 bytes)
|
|
|
|
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[] 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[] 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[] raceWind = ByteBuffer.allocate(2).put(shortToBytes(raceWindDir)).array();//North = 0x0000 East = 0x4000 South = 0x8000
|
|
|
|
byte[] windSpeed = ByteBuffer.allocate(2).putShort(raceWindSpeed).array();//mm/sec
|
|
|
|
byte[] windSpeed = ByteBuffer.allocate(2).put(shortToBytes(raceWindSpeed)).array();//mm/sec
|
|
|
|
byte[] numBoats = intToBytes(boats.size(), 1);
|
|
|
|
byte[] numBoats = intToBytes(boats.size(), 1);
|
|
|
|
byte[] bytesRaceType = intToBytes(raceType, 1);//1 match race, 2 fleet race
|
|
|
|
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[] 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.
|
|
|
|
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(legNum);
|
|
|
|
raceStatusMessage.put(numPenalties);
|
|
|
|
raceStatusMessage.put(numPenalties);
|
|
|
|
raceStatusMessage.put(numPenaltiesServed);
|
|
|
|
raceStatusMessage.put(numPenaltiesServed);
|
|
|
|
@ -120,7 +120,7 @@ public class RaceVisionByteEncoder {
|
|
|
|
result.put(timestamp);
|
|
|
|
result.put(timestamp);
|
|
|
|
result.put(ackNumber);
|
|
|
|
result.put(ackNumber);
|
|
|
|
result.put(raceStartTime);
|
|
|
|
result.put(raceStartTime);
|
|
|
|
result.putInt(raceIdentifier);
|
|
|
|
result.put(intToBytes(raceIdentifier));
|
|
|
|
result.put(notificationType);
|
|
|
|
result.put(notificationType);
|
|
|
|
|
|
|
|
|
|
|
|
return result.array();
|
|
|
|
return result.array();
|
|
|
|
@ -140,9 +140,9 @@ public class RaceVisionByteEncoder {
|
|
|
|
result.put(intToBytes(messageVersion, 1));
|
|
|
|
result.put(intToBytes(messageVersion, 1));
|
|
|
|
result.put(encodeTime);
|
|
|
|
result.put(encodeTime);
|
|
|
|
result.putShort(ackNum);
|
|
|
|
result.putShort(ackNum);
|
|
|
|
result.putInt(raceUID);
|
|
|
|
result.put(intToBytes(raceUID));
|
|
|
|
result.putInt(destSource);
|
|
|
|
result.put(intToBytes(destSource));
|
|
|
|
result.putInt(incident);
|
|
|
|
result.put(intToBytes(incident));
|
|
|
|
result.put(event);
|
|
|
|
result.put(event);
|
|
|
|
return result.array();
|
|
|
|
return result.array();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|