mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Discovered the time valid timestamp in the boat location packet is quite inconsistent and either the stream or my implementation is making the display really buggy. Because the way it was before I changed things is more reliable at the moment, I have decided to wait until our mock stream is merged before continuing this development. #story[820]
This commit is contained in:
@@ -58,13 +58,13 @@ public class StreamParser extends Thread{
|
||||
long sleepTime = 0;
|
||||
long transitTime = (System.currentTimeMillis()%loopTime - packet.getTimeStamp()%loopTime);
|
||||
if (transitTime < 0){
|
||||
transitTime = loopTime + delayTime;
|
||||
transitTime = loopTime + transitTime;
|
||||
}
|
||||
if (transitTime < delayTime) {
|
||||
sleepTime = delayTime - (transitTime);
|
||||
Thread.sleep(sleepTime);
|
||||
}
|
||||
System.out.println(sleepTime);
|
||||
// System.out.println(sleepTime);
|
||||
|
||||
packet = StreamReceiver.packetBuffer.take();
|
||||
parsePacket(packet);
|
||||
@@ -169,7 +169,7 @@ public class StreamParser extends Thread{
|
||||
System.out.println("RACE HAS STARTED");
|
||||
}
|
||||
if (timeTillStart % 10 == 0){
|
||||
System.out.println("Time since start: " + -1 * timeTillStart + " Seconds");
|
||||
//System.out.println("Time since start: " + -1 * timeTillStart + " Seconds");
|
||||
}
|
||||
}
|
||||
long windDir = bytesToLong(Arrays.copyOfRange(payload,18,20));
|
||||
@@ -332,6 +332,9 @@ public class StreamParser extends Thread{
|
||||
if ((int)deviceType == 1){
|
||||
|
||||
BoatPositionPacket boatPacket = new BoatPositionPacket(boatId, timeValid, lat, lon, heading, groundSpeed);
|
||||
if (boatId == 106){
|
||||
System.out.println("timeValid = " + timeValid);
|
||||
}
|
||||
|
||||
if (!boatPositions.containsKey(boatId)){
|
||||
boatPositions.put(boatId, new PriorityBlockingQueue<BoatPositionPacket>(256, new Comparator<BoatPositionPacket>() {
|
||||
|
||||
@@ -78,9 +78,6 @@ public class StreamReceiver extends Thread {
|
||||
long computedCrc = checksum.getValue();
|
||||
long packetCrc = bytesToLong(getBytes(4));
|
||||
if (computedCrc == packetCrc) {
|
||||
// System.out.println("message type: " + type);
|
||||
// System.out.println("timeStamp = " + timeStamp);
|
||||
// System.out.println("payload length: " + payloadLength);
|
||||
packetBuffer.add(new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||
} else {
|
||||
System.err.println("Packet has been dropped");
|
||||
@@ -126,7 +123,7 @@ public class StreamReceiver extends Thread {
|
||||
* takes an array of up to 7 bytes and returns a positive
|
||||
* long constructed from the input bytes
|
||||
*
|
||||
* @return a positive long if there is less than 7 bytes -1 otherwise
|
||||
* @return a positive long if there is less than 8 bytes -1 otherwise
|
||||
*/
|
||||
private long bytesToLong(byte[] bytes){
|
||||
long partialLong = 0;
|
||||
|
||||
@@ -20,4 +20,16 @@ public class BoatPositionPacket {
|
||||
public long getTimeValid() {
|
||||
return timeValid;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,11 @@ public class StreamPacket {
|
||||
private long timeStamp;
|
||||
private byte[] payload;
|
||||
|
||||
StreamPacket(int type, long messageLength, long timeStamp, byte[] payload) {
|
||||
public StreamPacket(int type, long messageLength, long timeStamp, byte[] payload) {
|
||||
this.type = PacketType.assignPacketType(type);
|
||||
this.messageLength = messageLength;
|
||||
this.timeStamp = timeStamp;
|
||||
this.payload = payload;
|
||||
// System.out.println("type = " + this.type.toString());
|
||||
//switch the packet type to deal with what ever specific packet you want to deal with
|
||||
// if (this.type == PacketType.XML_MESSAGE){
|
||||
// //System.out.println("--------");
|
||||
// System.out.println(new String(payload));
|
||||
// StreamParser.parsePacket(this);
|
||||
// }
|
||||
}
|
||||
|
||||
public PacketType getType() {
|
||||
|
||||
Reference in New Issue
Block a user