Merge branch 'splitIntoTwoModules' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into splitIntoTwoModules
This commit is contained in:
@@ -18,7 +18,8 @@ public class MockOutput implements Runnable
|
||||
|
||||
private RaceVisionByteEncoder messageEncoder = new RaceVisionByteEncoder();
|
||||
|
||||
//socket port 4945 as 4940 is ac35 live port and 4941 is ac35 test port
|
||||
//socket port 4942 as 4940 is ac35 live port and 4941 is ac35 test port
|
||||
private ServerSocket serverSocket;
|
||||
private Socket mockSocket;
|
||||
private DataOutputStream outToVisualiser;
|
||||
|
||||
@@ -31,20 +32,15 @@ public class MockOutput implements Runnable
|
||||
|
||||
|
||||
|
||||
public MockOutput() throws IOException {
|
||||
/*******************************Test********************************/
|
||||
StringBuilder xmlString;
|
||||
MockOutput() throws IOException {
|
||||
/**************sockets*******************/
|
||||
//start Time
|
||||
lastHeartbeatTime = System.currentTimeMillis();
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
this.getClass().getResourceAsStream(("/raceXML/Regatta.xml"))));
|
||||
|
||||
String line;
|
||||
xmlString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
xmlString.append(line.trim());
|
||||
}
|
||||
|
||||
parseXMLString(xmlString.toString(), 5);
|
||||
// mockSocket = new Socket("localhost", 4942);
|
||||
serverSocket = new ServerSocket(4942);
|
||||
// mockSocket = serverSocket.accept();
|
||||
|
||||
}
|
||||
/**
|
||||
@@ -97,19 +93,28 @@ public class MockOutput implements Runnable
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
/*******************************Test********************************/
|
||||
|
||||
/**************sockets*******************/
|
||||
//start Time
|
||||
lastHeartbeatTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
mockSocket = new Socket("localhost", 4945);
|
||||
while (true){
|
||||
mockSocket = serverSocket.accept();
|
||||
outToVisualiser = new DataOutputStream(mockSocket.getOutputStream());
|
||||
|
||||
/*******************************Test********************************/
|
||||
StringBuilder xmlString;
|
||||
|
||||
//loop that sends
|
||||
while (true) {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
this.getClass().getResourceAsStream(("/raceXML/Regatta.xml"))));
|
||||
|
||||
String line;
|
||||
xmlString = new StringBuilder();
|
||||
while((line=br.readLine())!= null){
|
||||
xmlString.append(line.trim());
|
||||
}
|
||||
|
||||
parseXMLString(xmlString.toString(), 5);
|
||||
|
||||
/*******************************Test********************************/
|
||||
|
||||
while(true) {
|
||||
try {
|
||||
//sends a heartbeat every 5 seconds
|
||||
if (timeSinceHeartbeat() >= 5.00) {
|
||||
outToVisualiser.write(heartbeat());
|
||||
@@ -125,6 +130,11 @@ public class MockOutput implements Runnable
|
||||
//cleans out buffer
|
||||
messagesToSendBuffer.clear();
|
||||
}
|
||||
}catch(SocketException e){
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -35,6 +35,8 @@ public class VisualiserInput
|
||||
ServerSocket visualiserSocket = new ServerSocket(4945);
|
||||
Socket connectionSocket = visualiserSocket.accept();
|
||||
|
||||
Socket connectionSocket = new Socket(InetAddress.getLocalHost(), 4942);
|
||||
|
||||
//this is the test data that streams form the AC35 website
|
||||
// Socket connectionSocket = new Socket("livedata.americascup.com",4941);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user