|
|
|
@ -37,9 +37,9 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
|
|
|
|
|
|
|
private Map<Integer, BoatLocationMessage> boatLocation;
|
|
|
|
private Map<Integer, BoatLocationMessage> boatLocation;
|
|
|
|
|
|
|
|
|
|
|
|
public VisualiserInput(StreamedCourse course) throws IOException{
|
|
|
|
public VisualiserInput(Socket socket, StreamedCourse course) throws IOException{
|
|
|
|
|
|
|
|
|
|
|
|
connectionSocket = new Socket(InetAddress.getLocalHost(), 4942);
|
|
|
|
this.connectionSocket = socket;
|
|
|
|
// this.connectionSocket = new Socket("livedata.americascup.com",4941);
|
|
|
|
// this.connectionSocket = new Socket("livedata.americascup.com",4941);
|
|
|
|
|
|
|
|
|
|
|
|
this.course = course;
|
|
|
|
this.course = course;
|
|
|
|
@ -125,17 +125,17 @@ public class VisualiserInput implements Runnable
|
|
|
|
lastHeartbeatTime = System.currentTimeMillis();
|
|
|
|
lastHeartbeatTime = System.currentTimeMillis();
|
|
|
|
//note: if the program runs for over 340 years, this will crash.
|
|
|
|
//note: if the program runs for over 340 years, this will crash.
|
|
|
|
heartbeatSeqNum = ByteConverter.bytesToLong(testDecoder.getMessage());
|
|
|
|
heartbeatSeqNum = ByteConverter.bytesToLong(testDecoder.getMessage());
|
|
|
|
System.out.println("HeartBeat Message! " + heartbeatSeqNum);
|
|
|
|
// System.out.println("HeartBeat Message! " + heartbeatSeqNum);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case RACESTATUS:
|
|
|
|
case RACESTATUS:
|
|
|
|
System.out.println("Race Status Message");
|
|
|
|
// System.out.println("Race Status Message");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DISPLAYTEXTMESSAGE:
|
|
|
|
case DISPLAYTEXTMESSAGE:
|
|
|
|
// System.out.println("Display Text Message");
|
|
|
|
// System.out.println("Display Text Message");
|
|
|
|
//no decoder for this.
|
|
|
|
//no decoder for this.
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case XMLMESSAGE:
|
|
|
|
case XMLMESSAGE:
|
|
|
|
System.out.println("XML Message!");
|
|
|
|
// System.out.println("XML Message!");
|
|
|
|
XMLMessage xml = (XMLMessage) data;
|
|
|
|
XMLMessage xml = (XMLMessage) data;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (xml.getXmlMsgSubType() == xml.XMLTypeRegatta){
|
|
|
|
if (xml.getXmlMsgSubType() == xml.XMLTypeRegatta){
|
|
|
|
@ -159,7 +159,7 @@ public class VisualiserInput implements Runnable
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case RACESTARTSTATUS:
|
|
|
|
case RACESTARTSTATUS:
|
|
|
|
//System.out.println("Race Start Status Message");
|
|
|
|
System.out.println("Race Start Status Message");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case YACHTEVENTCODE:
|
|
|
|
case YACHTEVENTCODE:
|
|
|
|
// System.out.println("Yacht Action Code!");
|
|
|
|
// System.out.println("Yacht Action Code!");
|
|
|
|
@ -174,6 +174,7 @@ public class VisualiserInput implements Runnable
|
|
|
|
//no decoder
|
|
|
|
//no decoder
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case BOATLOCATION:
|
|
|
|
case BOATLOCATION:
|
|
|
|
|
|
|
|
System.out.println("Boat Location!");
|
|
|
|
BoatLocationMessage msg = (BoatLocationMessage) data;
|
|
|
|
BoatLocationMessage msg = (BoatLocationMessage) data;
|
|
|
|
if (boatLocation.containsKey(msg.getSourceID())){
|
|
|
|
if (boatLocation.containsKey(msg.getSourceID())){
|
|
|
|
if (msg.getTime() > boatLocation.get(msg.getSourceID()).getTime()){
|
|
|
|
if (msg.getTime() > boatLocation.get(msg.getSourceID()).getTime()){
|
|
|
|
@ -212,7 +213,8 @@ public class VisualiserInput implements Runnable
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String argv[]) throws Exception
|
|
|
|
public static void main(String argv[]) throws Exception
|
|
|
|
{
|
|
|
|
{
|
|
|
|
VisualiserInput receiver = new VisualiserInput(new StreamedCourse());
|
|
|
|
Socket socket = new Socket(InetAddress.getLocalHost(), 4942);
|
|
|
|
|
|
|
|
VisualiserInput receiver = new VisualiserInput(socket, new StreamedCourse());
|
|
|
|
receiver.run();
|
|
|
|
receiver.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|