Merge remote-tracking branch 'origin/splitIntoTwoModules' into splitIntoTwoModules

This commit is contained in:
hba56
2017-05-01 16:08:28 +12:00
30 changed files with 490 additions and 683 deletions
@@ -1,7 +1,7 @@
package seng302.Networking;
import SharedModel.BoatInRace;
import com.sun.jmx.remote.internal.ArrayQueue;
import seng302.Model.Boat;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import seng302.Networking.Utils.BoatLocationMessage;
@@ -10,7 +10,7 @@ import seng302.Networking.Utils.RaceStatus;
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.concurrent.ArrayBlockingQueue;
/**
@@ -37,7 +37,7 @@ public class MockOutput implements Runnable
public MockOutput() throws IOException {
lastHeartbeatTime = System.currentTimeMillis();
serverSocket = new ServerSocket(5003);
serverSocket = new ServerSocket(4942);
}
/**
* calculates the time since last heartbeat
@@ -78,7 +78,7 @@ public class MockOutput implements Runnable
/**
* Used to give the mocOutput information about boat location to be made into a message and sent
*/
public synchronized void parseBoatLocation(BoatInRace boat){
public synchronized void parseBoatLocation(Boat boat){
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(boat, boatLocationSequenceNumber);
//iterates the sequence number
boatLocationSequenceNumber++;
@@ -4,9 +4,8 @@ package seng302.Networking.Utils;
* Created by f123 on 21-Apr-17.
*/
import SharedModel.BoatInRace;
import SharedModel.Constants;
import SharedModel.GPSCoordinate;
import seng302.Model.Boat;
import static seng302.Networking.Utils.AC35UnitConverter.convertGPSToInt;
@@ -151,7 +150,7 @@ public class BoatLocationMessage extends AC35Data
this.rudderAngle = rudderAngle;
}
public BoatLocationMessage(BoatInRace boat, long sequenceNumber) {
public BoatLocationMessage(Boat boat, long sequenceNumber) {
super(MessageType.BOATLOCATION);
this.messageVersionNumber = (byte) 1;
@@ -1,24 +1,17 @@
package seng302.Networking;
import org.xml.sax.SAXException;
import seng302.Mock.*;
import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.MessageDecoders.*;
import seng302.Networking.Utils.*;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static seng302.Networking.Utils.ByteConverter.bytesToInt;
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
import static seng302.Networking.Utils.MessageType.*;
/**
* TCP server to act as the mock AC35 streaming interface
@@ -39,7 +32,6 @@ public class VisualiserInput implements Runnable
public VisualiserInput(Socket connectionSocket) throws IOException{
//connectionSocket = new Socket(InetAddress.getLocalHost(), 4942);
this.connectionSocket = connectionSocket;
this.course = new StreamedCourse();
@@ -103,6 +95,7 @@ public class VisualiserInput implements Runnable
public void run(){
try{
System.out.println("running");
//receiver loop that gets the input
boolean receiverLoop = true;
while(receiverLoop) {
@@ -136,7 +129,7 @@ public class VisualiserInput implements Runnable
//no decoder for this.
break;
case XMLMESSAGE:
// System.out.println("XML Message!");
System.out.println("XML Message!");
XMLMessage xml = (XMLMessage) data;
try {
if (xml.getXmlMsgSubType() == xml.XMLTypeRegatta){
@@ -179,7 +172,7 @@ public class VisualiserInput implements Runnable
}else{
boatLocation.put(msg.getSourceID(), msg);
}
// System.out.println("Boat Location Message!");
System.out.println("Boat Location Message!");
break;
case MARKROUNDING:
// System.out.println("Mark Rounding Message!");
@@ -210,7 +203,9 @@ public class VisualiserInput implements Runnable
public static void main(String argv[]) throws Exception
{
//this is the test data that streams form the AC35 website
Socket socket = new Socket("livedata.americascup.com",4941);
Socket socket = new Socket(InetAddress.getLocalHost(), 4942);
// Socket socket = new Socket("livedata.americascup.com",4941);
VisualiserInput receiver = new VisualiserInput(socket);
receiver.run();
}