Merge branch 'cbt-multi-controller' into 'master'
Cbt multi controller Covers stories 4 and 6. See merge request !17
This commit is contained in:
Generated
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<transformer
|
<transformer
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Main-Class>mock.app.App</Main-Class>
|
<Main-Class>visualiser.app.App</Main-Class>
|
||||||
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
||||||
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
|
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package mock.app;
|
|
||||||
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import mock.dataInput.PolarParser;
|
|
||||||
import mock.model.Polars;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
import shared.dataInput.XMLReader;
|
|
||||||
import shared.enums.XMLFileType;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class App extends Application {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point for running the programme
|
|
||||||
*
|
|
||||||
* @param args for starting the programme
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage primaryStage) {
|
|
||||||
try {
|
|
||||||
Polars boatPolars = PolarParser.parse("mock/polars/acc_polars.csv");
|
|
||||||
|
|
||||||
String regattaXML = XMLReader.readXMLFileToString("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8);
|
|
||||||
String raceXML = XMLReader.readXMLFileToString("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8);
|
|
||||||
String boatXML = XMLReader.readXMLFileToString("mock/mockXML/boatTest.xml", StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
Event raceEvent = new Event(raceXML, regattaXML, boatXML, XMLFileType.Contents, boatPolars);
|
|
||||||
raceEvent.start();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
//Catch all exceptions, print, and exit.
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
package mock.app;
|
||||||
|
|
||||||
|
import network.Messages.Enums.XMLMessageType;
|
||||||
|
import network.Messages.LatestMessages;
|
||||||
|
import network.Messages.XMLMessage;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import visualiser.gameController.ControllerServer;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection acceptor for multiple clients
|
||||||
|
*/
|
||||||
|
public class ConnectionAcceptor implements Runnable {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Port to expose server on.
|
||||||
|
*/
|
||||||
|
private int serverPort = 4942;
|
||||||
|
/**
|
||||||
|
* Socket used to listen for clients on.
|
||||||
|
*/
|
||||||
|
private ServerSocket serverSocket;
|
||||||
|
//mock outputs
|
||||||
|
private ArrayBlockingQueue<MockOutput> mockOutputList = new ArrayBlockingQueue<>(16, true);
|
||||||
|
//latest messages
|
||||||
|
private LatestMessages latestMessages;
|
||||||
|
//Acknowledgement number for packets
|
||||||
|
private int ackNumber = 0;
|
||||||
|
//race xml sequence number
|
||||||
|
private short raceXMLSequenceNumber;
|
||||||
|
//boat xml sequence number
|
||||||
|
private short boatXMLSequenceNumber;
|
||||||
|
//regatta xml sequence number
|
||||||
|
private short regattaXMLSequenceNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection Acceptor Constructor
|
||||||
|
* @param latestMessages Latest messages to be sent
|
||||||
|
* @throws IOException if a server socket cannot be instantiated.
|
||||||
|
*/
|
||||||
|
public ConnectionAcceptor(LatestMessages latestMessages) throws IOException {
|
||||||
|
|
||||||
|
this.latestMessages =latestMessages;
|
||||||
|
this.serverSocket = new ServerSocket(serverPort);
|
||||||
|
CheckClientConnection checkClientConnection = new CheckClientConnection(mockOutputList);
|
||||||
|
new Thread(checkClientConnection).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() throws UnknownHostException {
|
||||||
|
return InetAddress.getLocalHost().getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServerPort() {
|
||||||
|
return serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the Acceptor
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while(true){//should be connections not filled up
|
||||||
|
try {
|
||||||
|
System.out.println("Waiting for a connection...");//TEMP DEBUG REMOVE
|
||||||
|
Socket mockSocket = serverSocket.accept();
|
||||||
|
DataOutputStream outToVisualiser = new DataOutputStream(mockSocket.getOutputStream());
|
||||||
|
MockOutput mockOutput = new MockOutput(latestMessages, outToVisualiser);
|
||||||
|
ControllerServer controllerServer = new ControllerServer(mockSocket);
|
||||||
|
new Thread(mockOutput).start();
|
||||||
|
new Thread(controllerServer).start();
|
||||||
|
mockOutputList.add(mockOutput);
|
||||||
|
System.out.println(String.format("%d number of Visualisers Connected.", mockOutputList.size()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nested class to remove disconnected clients
|
||||||
|
*/
|
||||||
|
class CheckClientConnection implements Runnable{
|
||||||
|
|
||||||
|
private ArrayBlockingQueue<MockOutput> mocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param mocks Mocks "connected"
|
||||||
|
*/
|
||||||
|
public CheckClientConnection(ArrayBlockingQueue<MockOutput> mocks){
|
||||||
|
this.mocks = mocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the remover.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
double timeSinceLastHeartBeat = System.currentTimeMillis();
|
||||||
|
while(true) {
|
||||||
|
//System.out.println(mocks.size());//used to see current amount of visualisers connected.
|
||||||
|
ArrayBlockingQueue<MockOutput> m = new ArrayBlockingQueue(16, true, mocks);
|
||||||
|
for (MockOutput mo : m) {
|
||||||
|
try {
|
||||||
|
mo.sendHeartBeat();
|
||||||
|
} catch (IOException e) {
|
||||||
|
mocks.remove(mo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Race XML to send.
|
||||||
|
* @param raceXml XML to send to the Client.
|
||||||
|
*/
|
||||||
|
public void setRaceXml(String raceXml) {
|
||||||
|
//Create the message.
|
||||||
|
XMLMessage message = this.createXMLMessage(raceXml, XMLMessageType.RACE);
|
||||||
|
|
||||||
|
//Place it in LatestMessages.
|
||||||
|
this.latestMessages.setRaceXMLMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Regatta XMl to send.
|
||||||
|
* @param regattaXml XML to send to Client.
|
||||||
|
*/
|
||||||
|
public void setRegattaXml(String regattaXml) {
|
||||||
|
//Create the message.
|
||||||
|
XMLMessage message = this.createXMLMessage(regattaXml, XMLMessageType.REGATTA);
|
||||||
|
|
||||||
|
//Place it in LatestMessages.
|
||||||
|
this.latestMessages.setRegattaXMLMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Boats XML to send.
|
||||||
|
* @param boatsXml XMl to send to the Client.
|
||||||
|
*/
|
||||||
|
public void setBoatsXml(String boatsXml) {
|
||||||
|
//Create the message.
|
||||||
|
XMLMessage message = this.createXMLMessage(boatsXml, XMLMessageType.BOAT);
|
||||||
|
|
||||||
|
//Place it in LatestMessages.
|
||||||
|
this.latestMessages.setBoatXMLMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an XMLMessage of a specified subtype using the xml contents string.
|
||||||
|
* @param xmlString The contents of the xml file.
|
||||||
|
* @param messageType The subtype of xml message (race, regatta, boat).
|
||||||
|
* @return The created XMLMessage object.
|
||||||
|
*/
|
||||||
|
private XMLMessage createXMLMessage(String xmlString, XMLMessageType messageType) {
|
||||||
|
|
||||||
|
//Get the correct sequence number to use, and increment it.
|
||||||
|
short sequenceNumber = 0;
|
||||||
|
if (messageType == XMLMessageType.RACE) {
|
||||||
|
sequenceNumber = this.raceXMLSequenceNumber;
|
||||||
|
this.raceXMLSequenceNumber++;
|
||||||
|
|
||||||
|
} else if (messageType == XMLMessageType.BOAT) {
|
||||||
|
sequenceNumber = this.boatXMLSequenceNumber;
|
||||||
|
this.boatXMLSequenceNumber++;
|
||||||
|
|
||||||
|
} else if (messageType == XMLMessageType.REGATTA) {
|
||||||
|
sequenceNumber = this.regattaXMLSequenceNumber;
|
||||||
|
this.regattaXMLSequenceNumber++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the message.
|
||||||
|
XMLMessage message = new XMLMessage(
|
||||||
|
XMLMessage.currentVersionNumber,
|
||||||
|
getNextAckNumber(),
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
messageType,
|
||||||
|
sequenceNumber,
|
||||||
|
xmlString);
|
||||||
|
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increments the ackNumber value, and returns it.
|
||||||
|
* @return Incremented ackNumber.
|
||||||
|
*/
|
||||||
|
private int getNextAckNumber(){
|
||||||
|
this.ackNumber++;
|
||||||
|
|
||||||
|
return this.ackNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package mock.app;
|
package mock.app;
|
||||||
|
|
||||||
|
import mock.dataInput.PolarParser;
|
||||||
import mock.model.MockRace;
|
import mock.model.MockRace;
|
||||||
import mock.model.Polars;
|
import mock.model.Polars;
|
||||||
import network.Messages.LatestMessages;
|
import network.Messages.LatestMessages;
|
||||||
@@ -11,7 +12,10 @@ import shared.exceptions.InvalidRegattaDataException;
|
|||||||
import shared.exceptions.XMLReaderException;
|
import shared.exceptions.XMLReaderException;
|
||||||
import shared.model.Constants;
|
import shared.model.Constants;
|
||||||
|
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@@ -20,6 +24,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
* A Race Event, this holds all of the race's information as well as handling the connection to its clients.
|
* A Race Event, this holds all of the race's information as well as handling the connection to its clients.
|
||||||
*/
|
*/
|
||||||
public class Event {
|
public class Event {
|
||||||
|
private static Event theEvent = new Event();
|
||||||
|
|
||||||
private String raceXML;
|
private String raceXML;
|
||||||
private String regattaXML;
|
private String regattaXML;
|
||||||
@@ -29,40 +34,45 @@ public class Event {
|
|||||||
|
|
||||||
private Polars boatPolars;
|
private Polars boatPolars;
|
||||||
|
|
||||||
private MockOutput mockOutput;
|
private ConnectionAcceptor mockOutput;
|
||||||
private LatestMessages latestMessages;
|
private LatestMessages latestMessages;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an event, using various XML files.
|
* Constructs an event, using various XML files.
|
||||||
* @param raceXML The race.xml file.
|
|
||||||
* @param regattaXML The regatta.xml file.
|
|
||||||
* @param boatXML The boat.xml file.
|
|
||||||
* @param type How to read the file - e.g., load as resource.
|
|
||||||
* @param boatPolars polars that the boat uses
|
|
||||||
*/
|
*/
|
||||||
public Event(String raceXML, String regattaXML, String boatXML, XMLFileType type, Polars boatPolars) {
|
private Event() {
|
||||||
|
try {
|
||||||
|
this.raceXML = getRaceXMLAtCurrentTime(XMLReader.readXMLFileToString("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8));
|
||||||
|
this.boatXML = XMLReader.readXMLFileToString("mock/mockXML/boatsSinglePlayer.xml", StandardCharsets.UTF_8);
|
||||||
|
this.regattaXML = XMLReader.readXMLFileToString("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8);
|
||||||
|
this.xmlFileType = XMLFileType.Contents;
|
||||||
|
|
||||||
this.raceXML = getRaceXMLAtCurrentTime(raceXML);
|
this.boatPolars = PolarParser.parse("mock/polars/acc_polars.csv");
|
||||||
this.boatXML = boatXML;
|
|
||||||
this.regattaXML = regattaXML;
|
|
||||||
|
|
||||||
this.xmlFileType = type;
|
|
||||||
|
|
||||||
this.boatPolars = boatPolars;
|
|
||||||
|
|
||||||
this.latestMessages = new LatestMessages();
|
this.latestMessages = new LatestMessages();
|
||||||
|
this.mockOutput = new ConnectionAcceptor(latestMessages);
|
||||||
|
}
|
||||||
try {
|
catch (IOException e) {
|
||||||
this.mockOutput = new MockOutput(this.latestMessages);
|
e.printStackTrace();
|
||||||
new Thread(mockOutput).start();
|
} catch (XMLReaderException e) {
|
||||||
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (TransformerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Event getEvent() {
|
||||||
|
return theEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() throws UnknownHostException {
|
||||||
|
return mockOutput.getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return mockOutput.getServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the initial race data and then begins race simulation.
|
* Sends the initial race data and then begins race simulation.
|
||||||
* @throws InvalidRaceDataException Thrown if the race xml file cannot be parsed.
|
* @throws InvalidRaceDataException Thrown if the race xml file cannot be parsed.
|
||||||
@@ -71,6 +81,7 @@ public class Event {
|
|||||||
* @throws InvalidRegattaDataException Thrown if the regatta xml file cannot be parsed.
|
* @throws InvalidRegattaDataException Thrown if the regatta xml file cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public void start() throws InvalidRaceDataException, XMLReaderException, InvalidBoatDataException, InvalidRegattaDataException {
|
public void start() throws InvalidRaceDataException, XMLReaderException, InvalidBoatDataException, InvalidRegattaDataException {
|
||||||
|
new Thread(mockOutput).start();
|
||||||
|
|
||||||
sendXMLs();
|
sendXMLs();
|
||||||
|
|
||||||
@@ -83,7 +94,6 @@ public class Event {
|
|||||||
MockRace newRace = new MockRace(boatDataSource, raceDataSource, regattaDataSource, this.latestMessages, this.boatPolars, Constants.RaceTimeScale);
|
MockRace newRace = new MockRace(boatDataSource, raceDataSource, regattaDataSource, this.latestMessages, this.boatPolars, Constants.RaceTimeScale);
|
||||||
|
|
||||||
new Thread(newRace).start();
|
new Thread(newRace).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,5 +130,4 @@ public class Event {
|
|||||||
return raceXML;
|
return raceXML;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,18 +29,6 @@ public class MockOutput implements Runnable
|
|||||||
*/
|
*/
|
||||||
private double heartbeatPeriod = 5.0;
|
private double heartbeatPeriod = 5.0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Port to expose server on.
|
|
||||||
*/
|
|
||||||
private int serverPort = 4942;
|
|
||||||
/**
|
|
||||||
* Socket used to listen for clients on.
|
|
||||||
*/
|
|
||||||
private ServerSocket serverSocket;
|
|
||||||
/**
|
|
||||||
* Socket used to communicate with a client.
|
|
||||||
*/
|
|
||||||
private Socket mockSocket;
|
|
||||||
/**
|
/**
|
||||||
* Output stream which wraps around mockSocket outstream.
|
* Output stream which wraps around mockSocket outstream.
|
||||||
*/
|
*/
|
||||||
@@ -60,22 +48,6 @@ public class MockOutput implements Runnable
|
|||||||
*/
|
*/
|
||||||
private int ackNumber = 1;
|
private int ackNumber = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sequence number for race xml messages.
|
|
||||||
*/
|
|
||||||
private short raceXMLSequenceNumber = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sequence number for boat xml messages.
|
|
||||||
*/
|
|
||||||
private short boatXMLSequenceNumber = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sequence number for regatta xml messages.
|
|
||||||
*/
|
|
||||||
private short regattaXMLSequenceNumber = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequence number for heartbeat messages.
|
* Sequence number for heartbeat messages.
|
||||||
*/
|
*/
|
||||||
@@ -86,13 +58,14 @@ public class MockOutput implements Runnable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor.
|
* Ctor.
|
||||||
* @param latestMessages The collection of messages to send to connected clients.
|
*
|
||||||
* @throws IOException if server socket cannot be opened.
|
* @throws IOException if server socket cannot be opened.
|
||||||
*/
|
*/
|
||||||
public MockOutput(LatestMessages latestMessages) throws IOException {
|
public MockOutput(LatestMessages latestMessages, DataOutputStream outToVisualiser) throws IOException {
|
||||||
|
|
||||||
|
this.outToVisualiser = outToVisualiser;
|
||||||
|
|
||||||
this.lastHeartbeatTime = System.currentTimeMillis();
|
this.lastHeartbeatTime = System.currentTimeMillis();
|
||||||
this.serverSocket = new ServerSocket(serverPort);
|
|
||||||
|
|
||||||
this.latestMessages = latestMessages;
|
this.latestMessages = latestMessages;
|
||||||
|
|
||||||
@@ -155,44 +128,6 @@ public class MockOutput implements Runnable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an XMLMessage of a specified subtype using the xml contents string.
|
|
||||||
* @param xmlString The contents of the xml file.
|
|
||||||
* @param messageType The subtype of xml message (race, regatta, boat).
|
|
||||||
* @return The created XMLMessage object.
|
|
||||||
*/
|
|
||||||
private XMLMessage createXMLMessage(String xmlString, XMLMessageType messageType) {
|
|
||||||
|
|
||||||
//Get the correct sequence number to use, and increment it.
|
|
||||||
short sequenceNumber = 0;
|
|
||||||
if (messageType == XMLMessageType.RACE) {
|
|
||||||
sequenceNumber = this.raceXMLSequenceNumber;
|
|
||||||
this.raceXMLSequenceNumber++;
|
|
||||||
|
|
||||||
} else if (messageType == XMLMessageType.BOAT) {
|
|
||||||
sequenceNumber = this.boatXMLSequenceNumber;
|
|
||||||
this.boatXMLSequenceNumber++;
|
|
||||||
|
|
||||||
} else if (messageType == XMLMessageType.REGATTA) {
|
|
||||||
sequenceNumber = this.regattaXMLSequenceNumber;
|
|
||||||
this.regattaXMLSequenceNumber++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create the message.
|
|
||||||
XMLMessage message = new XMLMessage(
|
|
||||||
XMLMessage.currentVersionNumber,
|
|
||||||
getNextAckNumber(),
|
|
||||||
System.currentTimeMillis(),
|
|
||||||
messageType,
|
|
||||||
sequenceNumber,
|
|
||||||
xmlString );
|
|
||||||
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes/serialises a XMLMessage message, and returns it.
|
* Encodes/serialises a XMLMessage message, and returns it.
|
||||||
* @param xmlMessage The XMLMessage message to serialise.
|
* @param xmlMessage The XMLMessage message to serialise.
|
||||||
@@ -266,6 +201,17 @@ public class MockOutput implements Runnable
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a heartbeat
|
||||||
|
* @throws IOException if the socket is no longer open at both ends the heartbeat returns an error.
|
||||||
|
*/
|
||||||
|
public void sendHeartBeat() throws IOException {
|
||||||
|
//Sends a heartbeat every so often.
|
||||||
|
if (timeSinceHeartbeat() >= heartbeatPeriod) {
|
||||||
|
outToVisualiser.write(parseHeartbeat(createHeartbeatMessage()));
|
||||||
|
lastHeartbeatTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sending loop of the Server
|
* Sending loop of the Server
|
||||||
@@ -274,11 +220,6 @@ public class MockOutput implements Runnable
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
while (!stop){
|
while (!stop){
|
||||||
//Wait for a client to connect.
|
|
||||||
System.out.println("Waiting for a connection...");//TEMP DEBUG REMOVE
|
|
||||||
mockSocket = serverSocket.accept();
|
|
||||||
|
|
||||||
outToVisualiser = new DataOutputStream(mockSocket.getOutputStream());
|
|
||||||
|
|
||||||
//Wait until all of the xml files have been set.
|
//Wait until all of the xml files have been set.
|
||||||
if (!this.latestMessages.hasAllXMLMessages()) {
|
if (!this.latestMessages.hasAllXMLMessages()) {
|
||||||
@@ -307,12 +248,6 @@ public class MockOutput implements Runnable
|
|||||||
long minimumFramePeriod = 16;
|
long minimumFramePeriod = 16;
|
||||||
if (framePeriod >= minimumFramePeriod) {
|
if (framePeriod >= minimumFramePeriod) {
|
||||||
|
|
||||||
//Sends a heartbeat every so often.
|
|
||||||
if (timeSinceHeartbeat() >= heartbeatPeriod) {
|
|
||||||
outToVisualiser.write(parseHeartbeat(createHeartbeatMessage()));
|
|
||||||
lastHeartbeatTime = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send XML messages.
|
//Send XML messages.
|
||||||
if (!sentXMLs) {
|
if (!sentXMLs) {
|
||||||
//Serialise them.
|
//Serialise them.
|
||||||
@@ -385,47 +320,4 @@ public class MockOutput implements Runnable
|
|||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Race XML to send.
|
|
||||||
* @param raceXml XML to send to the Client.
|
|
||||||
*/
|
|
||||||
public void setRaceXml(String raceXml) {
|
|
||||||
//Create the message.
|
|
||||||
XMLMessage message = this.createXMLMessage(raceXml, XMLMessageType.RACE);
|
|
||||||
|
|
||||||
//Place it in LatestMessages.
|
|
||||||
this.latestMessages.setRaceXMLMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Regatta XMl to send.
|
|
||||||
* @param regattaXml XML to send to Client.
|
|
||||||
*/
|
|
||||||
public void setRegattaXml(String regattaXml) {
|
|
||||||
//Create the message.
|
|
||||||
XMLMessage message = this.createXMLMessage(regattaXml, XMLMessageType.REGATTA);
|
|
||||||
|
|
||||||
//Place it in LatestMessages.
|
|
||||||
this.latestMessages.setRegattaXMLMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Boats XML to send.
|
|
||||||
* @param boatsXml XMl to send to the Client.
|
|
||||||
*/
|
|
||||||
public void setBoatsXml(String boatsXml) {
|
|
||||||
//Create the message.
|
|
||||||
XMLMessage message = this.createXMLMessage(boatsXml, XMLMessageType.BOAT);
|
|
||||||
|
|
||||||
//Place it in LatestMessages.
|
|
||||||
this.latestMessages.setBoatXMLMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String argv[]) throws Exception
|
|
||||||
{
|
|
||||||
MockOutput client = new MockOutput(new LatestMessages());
|
|
||||||
client.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,10 @@ public class BinaryMessageDecoder {
|
|||||||
AverageWindDecoder awDecoder = new AverageWindDecoder(messageBody);
|
AverageWindDecoder awDecoder = new AverageWindDecoder(messageBody);
|
||||||
return awDecoder.getAverageWind();
|
return awDecoder.getAverageWind();
|
||||||
|
|
||||||
|
case BOATACTION:
|
||||||
|
BoatActionDecoder baDecoder = new BoatActionDecoder(messageBody);
|
||||||
|
return new BoatAction(baDecoder.getBoatAction());
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//System.out.println("Broken Message!");
|
//System.out.println("Broken Message!");
|
||||||
//throw new InvalidMessageException("Broken message! Did not recognise message type: " + headerMessageType + ".");
|
//throw new InvalidMessageException("Broken message! Did not recognise message type: " + headerMessageType + ".");
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ public class BinaryMessageEncoder {
|
|||||||
this.fullMessage = tempFullMessageByteBuffer.array();
|
this.fullMessage = tempFullMessageByteBuffer.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a binary message from message type and message body.
|
||||||
|
* @param headerMessageType of message
|
||||||
|
* @param messageBody of message
|
||||||
|
*/
|
||||||
|
public BinaryMessageEncoder(MessageType headerMessageType, byte[] messageBody) {
|
||||||
|
this(headerMessageType, System.currentTimeMillis(), 69, (short)messageBody.length, messageBody);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the full encoded message. This includes the header, body, and CRC.
|
* Returns the full encoded message. This includes the header, body, and CRC.
|
||||||
* @return Full encoded message.
|
* @return Full encoded message.
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package network.MessageDecoders;
|
||||||
|
|
||||||
|
import network.Messages.Enums.BoatActionEnum;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class BoatActionDecoder {
|
||||||
|
byte byteBoatAction;
|
||||||
|
BoatActionEnum boatAction;
|
||||||
|
|
||||||
|
public BoatActionDecoder(byte[] encodedBoatAction) {
|
||||||
|
byteBoatAction = encodedBoatAction[0];
|
||||||
|
|
||||||
|
boatAction = BoatActionEnum.fromByte(byteBoatAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoatActionEnum getBoatAction() {
|
||||||
|
return boatAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -339,4 +339,11 @@ public class RaceVisionByteEncoder {
|
|||||||
return result.array();
|
return result.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] boatActionMessage(BoatAction boatAction){
|
||||||
|
ByteBuffer boatActionMessage = ByteBuffer.allocate(1);
|
||||||
|
boatActionMessage.put(intToBytes(boatAction.getBoatAction(), 1));
|
||||||
|
byte [] result = boatActionMessage.array();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package network.Messages;
|
||||||
|
|
||||||
|
import network.Messages.Enums.BoatActionEnum;
|
||||||
|
import network.Messages.Enums.MessageType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by David on 10/07/2017.
|
||||||
|
*/
|
||||||
|
public class BoatAction extends AC35Data {
|
||||||
|
|
||||||
|
private byte boatAction;
|
||||||
|
|
||||||
|
public BoatAction(BoatActionEnum boatAction){
|
||||||
|
super(MessageType.BOATACTION);
|
||||||
|
this.boatAction = boatAction.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getBoatAction() {
|
||||||
|
return boatAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package network.Messages.Enums;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boat actions
|
||||||
|
*/
|
||||||
|
public enum BoatActionEnum {
|
||||||
|
NOT_A_STATUS(-1),
|
||||||
|
AUTO_PILOT(1),
|
||||||
|
SAILS_IN(2),
|
||||||
|
SAILS_OUT(3),
|
||||||
|
TACK_GYBE(4),
|
||||||
|
UPWIND(5),
|
||||||
|
DOWNWIND(6);
|
||||||
|
|
||||||
|
private byte value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ctor. Creates a BoatActionEnum from a given primitive integer value, cast to a byte.
|
||||||
|
* @param value Integer, which is cast to byte, to construct from.
|
||||||
|
*/
|
||||||
|
private BoatActionEnum(int value) {
|
||||||
|
this.value = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the primitive value of the enum.
|
||||||
|
* @return Primitive value of the enum.
|
||||||
|
*/
|
||||||
|
public byte getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores a mapping between Byte values and BoatActionEnum values.
|
||||||
|
*/
|
||||||
|
private static final Map<Byte, BoatActionEnum> byteToStatusMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Static initialization block. Initializes the byteToStatusMap.
|
||||||
|
*/
|
||||||
|
static {
|
||||||
|
for (BoatActionEnum type : BoatActionEnum.values()) {
|
||||||
|
BoatActionEnum.byteToStatusMap.put(type.value, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the enumeration value which corresponds to a given byte value.
|
||||||
|
* @param boatActionEnum Byte value to convert to a BoatActionEnum value.
|
||||||
|
* @return The BoatActionEnum value which corresponds to the given byte value.
|
||||||
|
*/
|
||||||
|
public static BoatActionEnum fromByte(byte boatActionEnum) {
|
||||||
|
//Gets the corresponding MessageType from the map.
|
||||||
|
BoatActionEnum type = BoatActionEnum.byteToStatusMap.get(boatActionEnum);
|
||||||
|
|
||||||
|
if (type == null) {
|
||||||
|
//If the byte value wasn't found, return the NOT_A_STATUS boatActionEnum.
|
||||||
|
return BoatActionEnum.NOT_A_STATUS;
|
||||||
|
} else {
|
||||||
|
//Otherwise, return the boatActionEnum.
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ public enum MessageType {
|
|||||||
MARKROUNDING(38),
|
MARKROUNDING(38),
|
||||||
COURSEWIND(44),
|
COURSEWIND(44),
|
||||||
AVGWIND(47),
|
AVGWIND(47),
|
||||||
|
BOATACTION(100),
|
||||||
NOTAMESSAGE(0);
|
NOTAMESSAGE(0);
|
||||||
|
|
||||||
///Primitive value of the enum.
|
///Primitive value of the enum.
|
||||||
|
|||||||
@@ -289,8 +289,7 @@ public class LatestMessages extends Observable {
|
|||||||
* @return True if race, boat, and regatta have an xml message, false otherwise.
|
* @return True if race, boat, and regatta have an xml message, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean hasAllXMLMessages() {
|
public boolean hasAllXMLMessages() {
|
||||||
|
if (this.regattaXMLMessage == null || this.boatXMLMessage == null || this.raceXMLMessage == null) {
|
||||||
if ((this.regattaXMLMessage == null) || (this.boatXMLMessage == null) || (this.raceXMLMessage == null)) {
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ import javafx.scene.control.TableColumn;
|
|||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import mock.app.Event;
|
||||||
|
import shared.exceptions.InvalidBoatDataException;
|
||||||
|
import shared.exceptions.InvalidRaceDataException;
|
||||||
|
import shared.exceptions.InvalidRegattaDataException;
|
||||||
|
import shared.exceptions.XMLReaderException;
|
||||||
import visualiser.model.RaceConnection;
|
import visualiser.model.RaceConnection;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,19 +43,24 @@ public class ConnectionController extends Controller {
|
|||||||
|
|
||||||
private ObservableList<RaceConnection> connections;
|
private ObservableList<RaceConnection> connections;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents whether the client is currently hosting a game already - this is to ensure they don't launch multiple servers.
|
||||||
|
*/
|
||||||
|
private boolean currentlyHostingGame = false;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
// TODO - replace with config file
|
// TODO - replace with config file
|
||||||
connections = FXCollections.observableArrayList();
|
connections = FXCollections.observableArrayList();
|
||||||
connections.add(new RaceConnection("livedata.americascup.com", 4941));
|
|
||||||
connections.add(new RaceConnection("localhost", 4942));
|
|
||||||
|
|
||||||
connectionTable.setItems(connections);
|
connectionTable.setItems(connections);
|
||||||
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
|
||||||
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
|
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
|
||||||
|
|
||||||
connectionTable.getSelectionModel().selectedItemProperty().addListener((obs, prev, curr) -> {
|
connectionTable.getSelectionModel().selectedItemProperty().addListener((obs, prev, curr) -> {
|
||||||
if (curr != null && ((RaceConnection)curr).check()) connectButton.setDisable(false);
|
if (curr != null && curr.check()) connectButton.setDisable(false);
|
||||||
else connectButton.setDisable(true);
|
else connectButton.setDisable(true);
|
||||||
});
|
});
|
||||||
connectButton.setDisable(true);
|
connectButton.setDisable(true);
|
||||||
@@ -75,6 +86,7 @@ public class ConnectionController extends Controller {
|
|||||||
try{
|
try{
|
||||||
RaceConnection connection = connectionTable.getSelectionModel().getSelectedItem();
|
RaceConnection connection = connectionTable.getSelectionModel().getSelectedItem();
|
||||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||||
|
socket.setKeepAlive(true);
|
||||||
connectionWrapper.setVisible(false);
|
connectionWrapper.setVisible(false);
|
||||||
parent.enterLobby(socket);
|
parent.enterLobby(socket);
|
||||||
} catch (IOException e) { /* Never reached */ }
|
} catch (IOException e) { /* Never reached */ }
|
||||||
@@ -92,6 +104,34 @@ public class ConnectionController extends Controller {
|
|||||||
}catch(NumberFormatException e){
|
}catch(NumberFormatException e){
|
||||||
System.err.println("Port number entered is not a number");
|
System.err.println("Port number entered is not a number");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a new host
|
||||||
|
*/
|
||||||
|
public void addLocal() {
|
||||||
|
try {
|
||||||
|
//We don't want to host more than one game.
|
||||||
|
if (!currentlyHostingGame) {
|
||||||
|
Event game = Event.getEvent();
|
||||||
|
urlField.textProperty().set(game.getAddress());
|
||||||
|
portField.textProperty().set(Integer.toString(game.getPort()));
|
||||||
|
|
||||||
|
game.start();
|
||||||
|
addConnection();
|
||||||
|
|
||||||
|
currentlyHostingGame = true;
|
||||||
|
}
|
||||||
|
} catch (InvalidRaceDataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (XMLReaderException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidBoatDataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidRegattaDataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import visualiser.app.VisualiserInput;
|
import visualiser.app.VisualiserInput;
|
||||||
|
import visualiser.gameController.ControllerClient;
|
||||||
import visualiser.model.VisualiserBoat;
|
import visualiser.model.VisualiserBoat;
|
||||||
import visualiser.model.VisualiserRace;
|
import visualiser.model.VisualiserRace;
|
||||||
|
|
||||||
@@ -36,8 +37,8 @@ public class MainController extends Controller {
|
|||||||
* @param visualiserInput The object used to read packets from the race server.
|
* @param visualiserInput The object used to read packets from the race server.
|
||||||
* @param visualiserRace The object modelling the race.
|
* @param visualiserRace The object modelling the race.
|
||||||
*/
|
*/
|
||||||
public void beginRace(VisualiserInput visualiserInput, VisualiserRace visualiserRace) {
|
public void beginRace(VisualiserInput visualiserInput, VisualiserRace visualiserRace, ControllerClient controllerClient) {
|
||||||
raceController.startRace(visualiserInput, visualiserRace);
|
raceController.startRace(visualiserInput, visualiserRace, controllerClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ import javafx.animation.AnimationTimer;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.chart.LineChart;
|
import javafx.scene.chart.LineChart;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
@@ -16,8 +19,13 @@ import javafx.util.Callback;
|
|||||||
import network.Messages.Enums.RaceStatusEnum;
|
import network.Messages.Enums.RaceStatusEnum;
|
||||||
import shared.model.Leg;
|
import shared.model.Leg;
|
||||||
import visualiser.app.VisualiserInput;
|
import visualiser.app.VisualiserInput;
|
||||||
|
import visualiser.gameController.ControllerClient;
|
||||||
|
import visualiser.gameController.Keys.ControlKey;
|
||||||
|
import visualiser.gameController.Keys.KeyFactory;
|
||||||
import visualiser.model.*;
|
import visualiser.model.*;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@@ -52,6 +60,11 @@ public class RaceController extends Controller {
|
|||||||
*/
|
*/
|
||||||
private Sparkline sparkline;
|
private Sparkline sparkline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for sending keystrokes to server
|
||||||
|
*/
|
||||||
|
private ControllerClient controllerClient;
|
||||||
|
|
||||||
|
|
||||||
@FXML private GridPane canvasBase;
|
@FXML private GridPane canvasBase;
|
||||||
@FXML private Pane arrow;
|
@FXML private Pane arrow;
|
||||||
@@ -79,6 +92,22 @@ public class RaceController extends Controller {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
KeyFactory keyFactory = KeyFactory.getFactory();
|
||||||
|
|
||||||
|
// Initialise keyboard handler
|
||||||
|
race.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||||
|
String codeString = event.getCode().toString();
|
||||||
|
ControlKey controlKey = keyFactory.getKey(codeString);
|
||||||
|
if(controlKey != null) {
|
||||||
|
try {
|
||||||
|
controllerClient.sendKey(controlKey);
|
||||||
|
controlKey.onAction(); // Change key state if applicable
|
||||||
|
event.consume();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,8 +307,6 @@ public class RaceController extends Controller {
|
|||||||
|
|
||||||
//Add to scene.
|
//Add to scene.
|
||||||
canvasBase.getChildren().add(0, raceCanvas);
|
canvasBase.getChildren().add(0, raceCanvas);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -312,10 +339,11 @@ public class RaceController extends Controller {
|
|||||||
* @param visualiserInput Object used to read packets from server.
|
* @param visualiserInput Object used to read packets from server.
|
||||||
* @param visualiserRace Object modelling the race.
|
* @param visualiserRace Object modelling the race.
|
||||||
*/
|
*/
|
||||||
public void startRace(VisualiserInput visualiserInput, VisualiserRace visualiserRace) {
|
public void startRace(VisualiserInput visualiserInput, VisualiserRace visualiserRace, ControllerClient controllerClient) {
|
||||||
|
|
||||||
this.visualiserInput = visualiserInput;
|
this.visualiserInput = visualiserInput;
|
||||||
this.visualiserRace = visualiserRace;
|
this.visualiserRace = visualiserRace;
|
||||||
|
this.controllerClient = controllerClient;
|
||||||
|
|
||||||
initialiseRace();
|
initialiseRace();
|
||||||
|
|
||||||
@@ -345,7 +373,6 @@ public class RaceController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timer which monitors the race.
|
* Timer which monitors the race.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import shared.exceptions.InvalidRaceDataException;
|
|||||||
import shared.exceptions.InvalidRegattaDataException;
|
import shared.exceptions.InvalidRegattaDataException;
|
||||||
import shared.exceptions.XMLReaderException;
|
import shared.exceptions.XMLReaderException;
|
||||||
import visualiser.app.VisualiserInput;
|
import visualiser.app.VisualiserInput;
|
||||||
|
import visualiser.gameController.ControllerClient;
|
||||||
import visualiser.model.VisualiserBoat;
|
import visualiser.model.VisualiserBoat;
|
||||||
import visualiser.model.VisualiserRace;
|
import visualiser.model.VisualiserRace;
|
||||||
|
|
||||||
@@ -76,6 +77,8 @@ public class StartController extends Controller implements Observer {
|
|||||||
*/
|
*/
|
||||||
private VisualiserRace visualiserRace;
|
private VisualiserRace visualiserRace;
|
||||||
|
|
||||||
|
private ControllerClient controllerClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of colors used to assign colors to each boat - passed in to the VisualiserRace constructor.
|
* An array of colors used to assign colors to each boat - passed in to the VisualiserRace constructor.
|
||||||
*/
|
*/
|
||||||
@@ -258,7 +261,7 @@ public class StartController extends Controller implements Observer {
|
|||||||
startWrapper.setVisible(false);
|
startWrapper.setVisible(false);
|
||||||
start.setVisible(false);
|
start.setVisible(false);
|
||||||
|
|
||||||
parent.beginRace(visualiserInput, visualiserRace);
|
parent.beginRace(visualiserInput, visualiserRace, controllerClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
@@ -308,6 +311,8 @@ public class StartController extends Controller implements Observer {
|
|||||||
try {
|
try {
|
||||||
//Begin reading packets from the socket/server.
|
//Begin reading packets from the socket/server.
|
||||||
this.visualiserInput = new VisualiserInput(socket);
|
this.visualiserInput = new VisualiserInput(socket);
|
||||||
|
//Send controller input to server
|
||||||
|
this.controllerClient = new ControllerClient(socket);
|
||||||
//Store a reference to latestMessages so that we can observe it.
|
//Store a reference to latestMessages so that we can observe it.
|
||||||
LatestMessages latestMessages = this.visualiserInput.getLatestMessages();
|
LatestMessages latestMessages = this.visualiserInput.getLatestMessages();
|
||||||
latestMessages.addObserver(this);
|
latestMessages.addObserver(this);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class App extends Application {
|
|||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
Scene scene = new Scene(root, 1200, 800);
|
Scene scene = new Scene(root, 1200, 800);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setTitle("RaceVision - Team 7");
|
stage.setTitle("RaceVision - Team 7");
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
import static network.Utils.ByteConverter.bytesToShort;
|
import static network.Utils.ByteConverter.bytesToShort;
|
||||||
|
|
||||||
@@ -372,6 +373,4 @@ public class VisualiserInput implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package visualiser.gameController;
|
||||||
|
|
||||||
|
import network.BinaryMessageEncoder;
|
||||||
|
import network.MessageEncoders.RaceVisionByteEncoder;
|
||||||
|
import network.Messages.BoatAction;
|
||||||
|
import network.Messages.Enums.BoatActionEnum;
|
||||||
|
import network.Messages.Enums.MessageType;
|
||||||
|
import visualiser.gameController.Keys.ControlKey;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic service for sending key presses to game server
|
||||||
|
*/
|
||||||
|
public class ControllerClient {
|
||||||
|
/**
|
||||||
|
* Socket to server
|
||||||
|
*/
|
||||||
|
Socket socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output stream wrapper for socket to server
|
||||||
|
*/
|
||||||
|
DataOutputStream outputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise controller client with live socket.
|
||||||
|
* @param socket to server
|
||||||
|
*/
|
||||||
|
public ControllerClient(Socket socket) {
|
||||||
|
this.socket = socket;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.outputStream = new DataOutputStream(socket.getOutputStream());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a keypress to server
|
||||||
|
* @param key to send
|
||||||
|
* @throws IOException if socket write fails
|
||||||
|
*/
|
||||||
|
public void sendKey(ControlKey key) throws IOException {
|
||||||
|
int protocolCode = key.getProtocolCode();
|
||||||
|
if(protocolCode > -1) {
|
||||||
|
|
||||||
|
byte[] bytes = new byte[4];
|
||||||
|
ByteBuffer.wrap(bytes).putInt(key.getProtocolCode());
|
||||||
|
BoatActionEnum boatActionEnum = BoatActionEnum.fromByte(bytes[3]);
|
||||||
|
|
||||||
|
BoatAction boatAction = new BoatAction(boatActionEnum);
|
||||||
|
|
||||||
|
byte[] encodedBoatAction = RaceVisionByteEncoder.boatActionMessage(boatAction);
|
||||||
|
|
||||||
|
BinaryMessageEncoder binaryMessage = new BinaryMessageEncoder(MessageType.BOATACTION, System.currentTimeMillis(), 0,
|
||||||
|
(short) encodedBoatAction.length, encodedBoatAction);
|
||||||
|
|
||||||
|
System.out.println("Sending out key: " + boatActionEnum);
|
||||||
|
outputStream.write(binaryMessage.getFullMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package visualiser.gameController;
|
||||||
|
|
||||||
|
import network.BinaryMessageDecoder;
|
||||||
|
import network.MessageDecoders.BoatActionDecoder;
|
||||||
|
import network.Messages.Enums.BoatActionEnum;
|
||||||
|
import visualiser.gameController.Keys.ControlKey;
|
||||||
|
import visualiser.gameController.Keys.KeyFactory;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for dispatching key press data to race from client
|
||||||
|
*/
|
||||||
|
public class ControllerServer implements Runnable {
|
||||||
|
/**
|
||||||
|
* Socket to client
|
||||||
|
*/
|
||||||
|
private Socket socket;
|
||||||
|
/**
|
||||||
|
* Wrapper for input from client
|
||||||
|
*/
|
||||||
|
private DataInputStream inputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise server-side controller with live client socket
|
||||||
|
* @param socket to client
|
||||||
|
*/
|
||||||
|
public ControllerServer(Socket socket) {
|
||||||
|
this.socket = socket;
|
||||||
|
try {
|
||||||
|
this.inputStream = new DataInputStream(this.socket.getInputStream());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for controller key input from client and loop.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while(true) {
|
||||||
|
byte[] message = new byte[20];
|
||||||
|
try {
|
||||||
|
if (inputStream.available() > 0) {
|
||||||
|
inputStream.read(message);
|
||||||
|
BinaryMessageDecoder encodedMessage = new BinaryMessageDecoder(message);
|
||||||
|
BoatActionDecoder boatActionDecoder = new BoatActionDecoder(encodedMessage.getMessageBody());
|
||||||
|
BoatActionEnum decodedMessage = boatActionDecoder.getBoatAction();
|
||||||
|
System.out.println("Received key: " + decodedMessage);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package visualiser.gameController;
|
||||||
|
|
||||||
|
import javafx.animation.AnimationTimer;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import visualiser.gameController.Keys.ControlKey;
|
||||||
|
import visualiser.gameController.Keys.KeyFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static javafx.application.Application.launch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for checking what keys are currently being used
|
||||||
|
*/
|
||||||
|
public class InputChecker {
|
||||||
|
private HashMap<String, Boolean> currentlyActiveKeys = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller loop that detects key presses that runs parallel to the main scene.
|
||||||
|
* @param scene Scene the controller is to run in parallel with.
|
||||||
|
*/
|
||||||
|
public void runWithScene(Scene scene){
|
||||||
|
KeyFactory keyFactory = KeyFactory.getFactory();
|
||||||
|
|
||||||
|
scene.setOnKeyPressed(event -> {
|
||||||
|
String codeString = event.getCode().toString();
|
||||||
|
if (!currentlyActiveKeys.containsKey(codeString)) {
|
||||||
|
ControlKey controlKey = keyFactory.getKey(codeString);
|
||||||
|
if (controlKey != null) {
|
||||||
|
controlKey.onAction();
|
||||||
|
System.out.println(controlKey.toString() + " is Pressed.");
|
||||||
|
}
|
||||||
|
currentlyActiveKeys.put(codeString, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
scene.setOnKeyReleased(event -> {
|
||||||
|
String codeString = event.getCode().toString();
|
||||||
|
ControlKey controlKey = keyFactory.getKey(codeString);
|
||||||
|
if (controlKey != null) {
|
||||||
|
controlKey.onRelease();
|
||||||
|
System.out.println(controlKey.toString() + " is Released.");
|
||||||
|
}
|
||||||
|
currentlyActiveKeys.remove(event.getCode().toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
new AnimationTimer() {
|
||||||
|
@Override
|
||||||
|
public void handle(long now) {
|
||||||
|
for (String key: currentlyActiveKeys.keySet()){
|
||||||
|
ControlKey controlKey = keyFactory.getKey(key);
|
||||||
|
if (controlKey != null){
|
||||||
|
controlKey.onHold();
|
||||||
|
System.out.println(controlKey.toString() + " is Held.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// for (String key : InputKeys.stringKeysMap.keySet()){
|
||||||
|
// if (removeActiveKey(key)) {
|
||||||
|
// System.out.println(key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes a key from the active dictionary
|
||||||
|
* @param codeString string of the key press to remove
|
||||||
|
* @return whether or not the key has been removed or not.
|
||||||
|
*/
|
||||||
|
private boolean removeActiveKey(String codeString) {
|
||||||
|
Boolean isActive = currentlyActiveKeys.get(codeString);
|
||||||
|
|
||||||
|
if (isActive != null && isActive) {
|
||||||
|
currentlyActiveKeys.put(codeString, false);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key for the controller, part of the abstract factory KeyFactory
|
||||||
|
*/
|
||||||
|
public abstract class ControlKey {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
protected int protocolCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for key state with specified protocol code
|
||||||
|
* @param name of action
|
||||||
|
* @param protocolCode -1 if not sent
|
||||||
|
*/
|
||||||
|
public ControlKey(String name, int protocolCode) {
|
||||||
|
this.name = name;
|
||||||
|
this.protocolCode = protocolCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for key state not sent over network
|
||||||
|
* @param name name of the key
|
||||||
|
*/
|
||||||
|
public ControlKey(String name){
|
||||||
|
this.name = name;
|
||||||
|
this.protocolCode = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProtocolCode() {
|
||||||
|
return protocolCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To String method
|
||||||
|
* @return returns the name of the key
|
||||||
|
*/
|
||||||
|
public String toString(){
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What this key should do when the command is issued for it to do its job.
|
||||||
|
*/
|
||||||
|
public abstract void onAction();//may want to make it take in a visualiser and stuff in the future.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What to do when the key is held
|
||||||
|
*/
|
||||||
|
public abstract void onHold();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What to do when the key is released.
|
||||||
|
*/
|
||||||
|
public abstract void onRelease();
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key to send downwind packet to server
|
||||||
|
*/
|
||||||
|
public class DownWindKey extends ControlKey {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
* @param name name of the key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DownWindKey(String name) {
|
||||||
|
super(name, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for creating Keys, these could be predefined in the future.
|
||||||
|
*/
|
||||||
|
public class KeyFactory {
|
||||||
|
/**
|
||||||
|
* Retrieve command given key
|
||||||
|
*/
|
||||||
|
private Map<String, ControlKey> keyState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton instance to enforce consistent key state
|
||||||
|
*/
|
||||||
|
private static KeyFactory theFactory = new KeyFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton constructor for key state, set up initial state of each action.
|
||||||
|
*/
|
||||||
|
private KeyFactory() {
|
||||||
|
this.keyState = new HashMap<>();
|
||||||
|
keyState.put("Z", new ZoomInKey("Zoom In"));
|
||||||
|
keyState.put("X", new ZoomOutKey("Zoom Out"));
|
||||||
|
keyState.put("SPACE", new VMGKey("VMG"));
|
||||||
|
keyState.put("SHIFT", new SailsToggleKey("Toggle Sails"));
|
||||||
|
keyState.put("ENTER", new TackGybeKey("Tack/Gybe"));
|
||||||
|
keyState.put("PAGE_UP", new UpWindKey("Upwind"));
|
||||||
|
keyState.put("PAGE_DOWN", new DownWindKey("Downwind"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get singleton instance of KeyFactory to interact with key state
|
||||||
|
* @return automatically constructed KeyFactory
|
||||||
|
*/
|
||||||
|
public static KeyFactory getFactory() {
|
||||||
|
return theFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Control Key in charge of a key press
|
||||||
|
* @param key key pressed (String value of KeyCode)
|
||||||
|
* @return the Control Key behaviour of the key pressed.
|
||||||
|
*/
|
||||||
|
public ControlKey getKey(String key){
|
||||||
|
return keyState.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key to toggle the sails
|
||||||
|
*/
|
||||||
|
public class SailsToggleKey extends ControlKey {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
* @param name name of the key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SailsToggleKey(String name) {
|
||||||
|
super(name, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle command associated with sails key
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
protocolCode = protocolCode == 2? 3 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key to toggle between tacking and gybing
|
||||||
|
*/
|
||||||
|
public class TackGybeKey extends ControlKey {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
* @param name name of the key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public TackGybeKey(String name) {
|
||||||
|
super(name, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key to go upwind
|
||||||
|
*/
|
||||||
|
public class UpWindKey extends ControlKey {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
* @param name name of the key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public UpWindKey(String name) {
|
||||||
|
super(name, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key to trigger auto VMG
|
||||||
|
*/
|
||||||
|
public class VMGKey extends ControlKey{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
*
|
||||||
|
* @param name name of the key
|
||||||
|
*/
|
||||||
|
public VMGKey(String name) {
|
||||||
|
super(name, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key to zoom into the game
|
||||||
|
*/
|
||||||
|
public class ZoomInKey extends ControlKey {
|
||||||
|
|
||||||
|
public ZoomInKey(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package visualiser.gameController.Keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key to zoom out of the game.
|
||||||
|
*/
|
||||||
|
public class ZoomOutKey extends ControlKey{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Control
|
||||||
|
* @param name name of the key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ZoomOutKey(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHold() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRelease() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,11 @@ public class RaceConnection {
|
|||||||
private final int port;
|
private final int port;
|
||||||
private final StringProperty status;
|
private final StringProperty status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for remote host connections.
|
||||||
|
* @param hostname URL for remote host
|
||||||
|
* @param port port for game feed
|
||||||
|
*/
|
||||||
public RaceConnection(String hostname, int port) {
|
public RaceConnection(String hostname, int port) {
|
||||||
this.hostname = new SimpleStringProperty(hostname);
|
this.hostname = new SimpleStringProperty(hostname);
|
||||||
this.port = port;
|
this.port = port;
|
||||||
@@ -33,6 +38,10 @@ public class RaceConnection {
|
|||||||
try (Socket s = new Socket()){
|
try (Socket s = new Socket()){
|
||||||
s.connect(i, 750);//TODO this should be at least a second or two, once moved to its own thread
|
s.connect(i, 750);//TODO this should be at least a second or two, once moved to its own thread
|
||||||
status.set("Ready");
|
status.set("Ready");
|
||||||
|
s.shutdownInput();
|
||||||
|
s.shutdownOutput();
|
||||||
|
s.close();
|
||||||
|
//System.out.println(String.valueOf(s.isClosed()));
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
|
|
||||||
|
|||||||
@@ -33,23 +33,8 @@
|
|||||||
</Boat>
|
</Boat>
|
||||||
|
|
||||||
<!--Participants-->
|
<!--Participants-->
|
||||||
<Boat BoatName="Team ORACLE USA" HullNum="RG01" ShapeID="0" ShortName="USA" SourceID="121" StoweName="USA" Type="Yacht">
|
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
|
||||||
</Boat>
|
|
||||||
<Boat BoatName="Land Rover BAR" HullNum="RG01" ShapeID="0" ShortName="GBR" SourceID="122" StoweName="GBR" Type="Yacht">
|
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
|
||||||
</Boat>
|
|
||||||
<Boat BoatName="SoftBank Team Japan" HullNum="RG01" ShapeID="0" ShortName="JPN" SourceID="123" StoweName="JPN" Type="Yacht">
|
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
|
||||||
</Boat>
|
|
||||||
<Boat BoatName="Groupama Team France" HullNum="RG01" ShapeID="0" ShortName="FRA" SourceID="124" StoweName="FRA" Type="Yacht">
|
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
|
||||||
</Boat>
|
|
||||||
<Boat BoatName="Artemis Racing" HullNum="RG01" ShapeID="0" ShortName="SWE" SourceID="125" StoweName="SWE" Type="Yacht">
|
<Boat BoatName="Artemis Racing" HullNum="RG01" ShapeID="0" ShortName="SWE" SourceID="125" StoweName="SWE" Type="Yacht">
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
</Boat>
|
</Boat>
|
||||||
<Boat BoatName="Emirates Team New Zealand" HullNum="RG01" ShapeID="0" ShortName="NZL" SourceID="126" StoweName="NZL" Type="Yacht">
|
|
||||||
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
|
||||||
</Boat>
|
|
||||||
</Boats>
|
</Boats>
|
||||||
</BoatConfig>
|
</BoatConfig>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
|
||||||
|
<BoatConfig>
|
||||||
|
<Boats>
|
||||||
|
|
||||||
|
<!--Mark Boats-->
|
||||||
|
<Boat Type="Mark" BoatName="PRO" SourceID="101" >
|
||||||
|
<GPSposition X= "-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="PIN" SourceID="102" >
|
||||||
|
<GPSposition X= "-64.855242" Y="32.293771" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="Marker1" SourceID="103" >
|
||||||
|
<GPSposition X= "-64.843983" Y="32.293039" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="WGL" SourceID="104" >
|
||||||
|
<GPSposition X= "-64.850045" Y="32.28468" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="WGR" SourceID="105" >
|
||||||
|
<GPSposition X= "-64.847591" Y="32.280164" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="LGL" SourceID="106" >
|
||||||
|
<GPSposition X= "-64.835249" Y="32.309693" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="LGR" SourceID="107" >
|
||||||
|
<GPSposition X= "-64.831785" Y="32.308046" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="FL" SourceID="108" >
|
||||||
|
<GPSposition X= "-64.839291" Y="32.317379" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat Type="Mark" BoatName="FR" SourceID="109" >
|
||||||
|
<GPSposition X= "-64.83626" Y="32.317257" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
|
||||||
|
<!--Participants-->
|
||||||
|
<Boat BoatName="Emirates Team New Zealand" HullNum="RG01" ShapeID="0" ShortName="NZL" SourceID="126" StoweName="NZL" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat BoatName="Land Rover BAR" HullNum="RG01" ShapeID="0" ShortName="GBR" SourceID="122" StoweName="GBR" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat BoatName="SoftBank Team Japan" HullNum="RG01" ShapeID="0" ShortName="JPN" SourceID="123" StoweName="JPN" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat BoatName="Groupama Team France" HullNum="RG01" ShapeID="0" ShortName="FRA" SourceID="124" StoweName="FRA" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat BoatName="Artemis Racing" HullNum="RG01" ShapeID="0" ShortName="SWE" SourceID="125" StoweName="SWE" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
<Boat BoatName="Emirates Team New Zealand" HullNum="RG01" ShapeID="0" ShortName="NZL" SourceID="126" StoweName="NZL" Type="Yacht">
|
||||||
|
<GPSposition X="-64.854304" Y="32.296577" Z="0"/>
|
||||||
|
</Boat>
|
||||||
|
</Boats>
|
||||||
|
</BoatConfig>
|
||||||
@@ -5,12 +5,7 @@
|
|||||||
<CreationTimeDate>CREATION_TIME</CreationTimeDate>
|
<CreationTimeDate>CREATION_TIME</CreationTimeDate>
|
||||||
<RaceStartTime Postpone="false" Time="START_TIME"/>
|
<RaceStartTime Postpone="false" Time="START_TIME"/>
|
||||||
<Participants>
|
<Participants>
|
||||||
<Yacht SourceID="121"/>
|
|
||||||
<Yacht SourceID="122"/>
|
|
||||||
<Yacht SourceID="123"/>
|
|
||||||
<Yacht SourceID="124"/>
|
|
||||||
<Yacht SourceID="125"/>
|
<Yacht SourceID="125"/>
|
||||||
<Yacht SourceID="126"/>
|
|
||||||
</Participants>
|
</Participants>
|
||||||
<CompoundMarkSequence>
|
<CompoundMarkSequence>
|
||||||
<Corner CompoundMarkID="1" SeqID="1"/>
|
<Corner CompoundMarkID="1" SeqID="1"/>
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TableColumn?>
|
||||||
|
<?import javafx.scene.control.TableView?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ConnectionController">
|
|
||||||
|
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ConnectionController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="600.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="80.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="600.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="308.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="301.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="80.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="182.0" minHeight="10.0" prefHeight="182.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="182.0" minHeight="10.0" prefHeight="182.0" vgrow="SOMETIMES" />
|
||||||
@@ -18,42 +28,43 @@
|
|||||||
<RowConstraints maxHeight="80.0" minHeight="50.0" prefHeight="80.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="80.0" minHeight="50.0" prefHeight="80.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<TableView fx:id="connectionTable" prefHeight="200.0" prefWidth="1080.0" GridPane.columnSpan="2" GridPane.rowIndex="1">
|
<TableView fx:id="connectionTable" prefHeight="200.0" prefWidth="1080.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="hostnameColumn" prefWidth="453.99998474121094" text="Host" />
|
<TableColumn fx:id="hostnameColumn" prefWidth="453.99998474121094" text="Host" />
|
||||||
<TableColumn fx:id="statusColumn" prefWidth="205.0" text="Status" />
|
<TableColumn fx:id="statusColumn" prefWidth="205.0" text="Status" />
|
||||||
</columns>
|
</columns>
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets left="50.0" right="50.0" />
|
<Insets />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TableView>
|
</TableView>
|
||||||
<Button mnemonicParsing="false" onAction="#checkConnections" text="Refresh" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
|
<Button mnemonicParsing="false" onAction="#checkConnections" text="Refresh" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets right="20.0" />
|
<Insets right="20.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Button fx:id="connectButton" mnemonicParsing="false" onAction="#connectSocket" text="Connect" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="3">
|
<Button fx:id="connectButton" mnemonicParsing="false" onAction="#connectSocket" text="Connect" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.rowIndex="3">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets left="20.0" />
|
<Insets left="20.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Label text="Welcome to RaceVision" GridPane.columnSpan="2" GridPane.halignment="CENTER">
|
<Label text="Welcome to RaceVision" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font size="36.0" />
|
<Font size="36.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<GridPane GridPane.columnSpan="2" GridPane.rowIndex="2">
|
<GridPane GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="2">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="447.0" minWidth="10.0" prefWidth="375.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="441.0" minWidth="10.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="381.0" minWidth="10.0" prefWidth="111.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="270.0" minWidth="10.0" prefWidth="103.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="urlField" GridPane.rowIndex="1">
|
<TextField fx:id="urlField" prefHeight="27.0" prefWidth="347.0" GridPane.rowIndex="1">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
@@ -63,9 +74,10 @@
|
|||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
<Button mnemonicParsing="false" onAction="#addConnection" text="Add New Connection" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
<Button mnemonicParsing="false" onAction="#addConnection" text="Add Remote" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||||
<Label text="Host Name:" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
|
<Label text="Host Name:" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
|
||||||
<Label text="Port:" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
|
<Label text="Port:" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#addLocal" text="Host" GridPane.columnIndex="3" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package visualiser.gameController;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.WindowEvent;
|
||||||
|
import visualiser.gameController.InputChecker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start to manually test the game controller
|
||||||
|
*/
|
||||||
|
public class GameControllerManualTest extends Application {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage stage) throws Exception {
|
||||||
|
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||||
|
@Override
|
||||||
|
public void handle(WindowEvent event) {
|
||||||
|
Platform.exit();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GridPane root = new GridPane();
|
||||||
|
Scene scene = new Scene(root, 1200, 800);
|
||||||
|
|
||||||
|
InputChecker inputChecker = new InputChecker();
|
||||||
|
inputChecker.runWithScene(scene);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("RaceVision - Team 7 - Input Tester Manual Test");
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user