You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
67 lines
1.6 KiB
package network.MessageDecoders;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import static network.Utils.ByteConverter.*;
|
|
|
|
|
|
/**
|
|
* Created by hba56 on 21/04/17.
|
|
*/
|
|
public class RaceStartStatusDecoder {
|
|
private byte messageVersion;
|
|
private byte[] timestamp;
|
|
private byte[] ackNumber;
|
|
private byte[] raceStartTime;
|
|
private byte[] raceIdentifier;
|
|
private byte notificationType;
|
|
|
|
private long time;
|
|
private short ack;
|
|
private long startTime;
|
|
private int raceID;
|
|
private char notification;
|
|
|
|
|
|
public RaceStartStatusDecoder(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];
|
|
|
|
time = bytesToLong(timestamp);
|
|
ack = bytesToShort(ackNumber);
|
|
startTime = bytesToLong(raceStartTime);
|
|
raceID = bytesToInt(raceIdentifier);
|
|
notification = bytesToChar(notificationType);
|
|
}
|
|
|
|
|
|
public byte getMessageVersion() {
|
|
return messageVersion;
|
|
}
|
|
|
|
public long getTime() {
|
|
return time;
|
|
}
|
|
|
|
public short getAck() {
|
|
return ack;
|
|
}
|
|
|
|
public long getStartTime() {
|
|
return startTime;
|
|
}
|
|
|
|
public int getRaceID() {
|
|
return raceID;
|
|
}
|
|
|
|
public char getNotification() {
|
|
return notification;
|
|
}
|
|
}
|