Deleted Unecessary code
- StreamedRace no longer sets the positions of boats - The Visualiser has blocking queue removed - The Regatta XML Reader not longer has a variable to the deleted Regatta class #story[881]
This commit is contained in:
@@ -14,7 +14,6 @@ import java.io.InputStream;
|
|||||||
* Created by jjg64 on 19/04/17.
|
* Created by jjg64 on 19/04/17.
|
||||||
*/
|
*/
|
||||||
public class RegattaXMLReader extends XMLReader {
|
public class RegattaXMLReader extends XMLReader {
|
||||||
private Regatta regatta;
|
|
||||||
private int regattaID;
|
private int regattaID;
|
||||||
private String regattaName;
|
private String regattaName;
|
||||||
private int raceID = 0;
|
private int raceID = 0;
|
||||||
@@ -78,10 +77,6 @@ public class RegattaXMLReader extends XMLReader {
|
|||||||
this.magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation"));
|
this.magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Regatta getRegatta() {
|
|
||||||
return regatta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRegattaID() {
|
public int getRegattaID() {
|
||||||
return regattaID;
|
return regattaID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class StreamedRace implements Runnable {
|
public class StreamedRace implements Runnable {
|
||||||
private final VisualiserInput visualiserInput;
|
private final VisualiserInput visualiserInput;
|
||||||
protected final ObservableList<Boat> startingBoats;
|
private final ObservableList<Boat> startingBoats;
|
||||||
protected final ObservableList<Marker> boatMarkers;
|
private final ObservableList<Marker> boatMarkers;
|
||||||
protected final List<Leg> legs;
|
private final List<Leg> legs;
|
||||||
private RaceController controller;
|
private RaceController controller;
|
||||||
protected FinishController finishController;
|
protected FinishController finishController;
|
||||||
protected int boatsFinished = 0;
|
private int boatsFinished = 0;
|
||||||
private long totalTimeElapsed;
|
private long totalTimeElapsed;
|
||||||
|
|
||||||
private int lastFPS = 20;
|
private int lastFPS = 20;
|
||||||
@@ -46,7 +46,7 @@ public class StreamedRace implements Runnable {
|
|||||||
this.visualiserInput = visualiserInput;
|
this.visualiserInput = visualiserInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialiseBoats() {
|
private void initialiseBoats() {
|
||||||
Leg officialStart = legs.get(0);
|
Leg officialStart = legs.get(0);
|
||||||
String name = officialStart.getName();
|
String name = officialStart.getName();
|
||||||
Marker endMarker = officialStart.getEndMarker();
|
Marker endMarker = officialStart.getEndMarker();
|
||||||
@@ -75,7 +75,7 @@ public class StreamedRace implements Runnable {
|
|||||||
* @param boat Boat that the position is to be updated for.
|
* @param boat Boat that the position is to be updated for.
|
||||||
* @param timeElapsed Time that has elapse since the start of the the race.
|
* @param timeElapsed Time that has elapse since the start of the the race.
|
||||||
*/
|
*/
|
||||||
protected void checkPosition(Boat boat, long timeElapsed) {
|
private void checkPosition(Boat boat, long timeElapsed) {
|
||||||
StreamedCourse raceData = visualiserInput.getCourse();
|
StreamedCourse raceData = visualiserInput.getCourse();
|
||||||
BoatStatus boatStatusMessage = visualiserInput.getBoatStatusMap().get(boat.getSourceID());
|
BoatStatus boatStatusMessage = visualiserInput.getBoatStatusMap().get(boat.getSourceID());
|
||||||
if (boatStatusMessage != null) {
|
if (boatStatusMessage != null) {
|
||||||
@@ -95,7 +95,7 @@ public class StreamedRace implements Runnable {
|
|||||||
boatsFinished++;
|
boatsFinished++;
|
||||||
boat.setTimeFinished(timeElapsed);
|
boat.setTimeFinished(timeElapsed);
|
||||||
boat.setFinished(true);
|
boat.setFinished(true);
|
||||||
System.out.println("Boat finished");
|
//System.out.println("Boat finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Update the boat display table in the GUI to reflect the leg change
|
//Update the boat display table in the GUI to reflect the leg change
|
||||||
@@ -108,7 +108,7 @@ public class StreamedRace implements Runnable {
|
|||||||
* @param boat to be updated
|
* @param boat to be updated
|
||||||
* @param millisecondsElapsed time since last update
|
* @param millisecondsElapsed time since last update
|
||||||
*/
|
*/
|
||||||
protected void updatePosition(Boat boat, int millisecondsElapsed) {
|
private void updatePosition(Boat boat, int millisecondsElapsed) {
|
||||||
int sourceID = boat.getSourceID();
|
int sourceID = boat.getSourceID();
|
||||||
BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID);
|
BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID);
|
||||||
if(boatLocation != null) {
|
if(boatLocation != null) {
|
||||||
@@ -126,7 +126,7 @@ public class StreamedRace implements Runnable {
|
|||||||
*
|
*
|
||||||
* @param mark to be updated
|
* @param mark to be updated
|
||||||
*/
|
*/
|
||||||
protected void updateMarker(Marker mark) {
|
private void updateMarker(Marker mark) {
|
||||||
int sourceID = mark.getSourceId1();
|
int sourceID = mark.getSourceId1();
|
||||||
BoatLocation boatLocation1 = visualiserInput.getBoatLocationMessage(sourceID);
|
BoatLocation boatLocation1 = visualiserInput.getBoatLocationMessage(sourceID);
|
||||||
if(boatLocation1 != null) {
|
if(boatLocation1 != null) {
|
||||||
@@ -143,16 +143,6 @@ public class StreamedRace implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* sets the position of a boat from coordinate
|
|
||||||
* @param boat the boat to set
|
|
||||||
* @param coordinate the position of the boat
|
|
||||||
*/
|
|
||||||
protected void setPosition(Boat boat, GPSCoordinate coordinate) {
|
|
||||||
boat.setCurrentPosition(coordinate);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setController(RaceController controller) {
|
public void setController(RaceController controller) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
@@ -164,7 +154,7 @@ public class StreamedRace implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
setControllerListeners();
|
setControllerListeners();
|
||||||
initialiseBoats();
|
initialiseBoats();
|
||||||
simulateRace();
|
startRaceStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,7 +171,7 @@ public class StreamedRace implements Runnable {
|
|||||||
* Starts the Race Simulation, playing the race start to finish with the timescale.
|
* Starts the Race Simulation, playing the race start to finish with the timescale.
|
||||||
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
|
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
|
||||||
*/
|
*/
|
||||||
private void simulateRace() {
|
private void startRaceStream() {
|
||||||
|
|
||||||
System.setProperty("javafx.animation.fullspeed", "true");
|
System.setProperty("javafx.animation.fullspeed", "true");
|
||||||
|
|
||||||
@@ -235,7 +225,7 @@ public class StreamedRace implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Update position of boats in race, no position if on starting leg or DNF.
|
* Update position of boats in race, no position if on starting leg or DNF.
|
||||||
*/
|
*/
|
||||||
protected void updatePositions() {
|
private void updatePositions() {
|
||||||
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
|
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
|
||||||
for(Boat boat: startingBoats) {
|
for(Boat boat: startingBoats) {
|
||||||
if(boat != null) {
|
if(boat != null) {
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
|||||||
*/
|
*/
|
||||||
public class VisualiserInput implements Runnable {
|
public class VisualiserInput implements Runnable {
|
||||||
|
|
||||||
///A queue that contains messages that have been received, and need to be handled.
|
|
||||||
private final ArrayBlockingQueue<AC35Data> messagesReceivedQueue = new ArrayBlockingQueue<>(1000000);//We have room for 1,000,000. Is this much capacity actually needed?
|
|
||||||
|
|
||||||
///Timestamp of the last heartbeat.
|
///Timestamp of the last heartbeat.
|
||||||
private long lastHeartbeatTime = -1;
|
private long lastHeartbeatTime = -1;
|
||||||
///Sequence number of the last heartbeat.
|
///Sequence number of the last heartbeat.
|
||||||
@@ -257,11 +254,7 @@ public class VisualiserInput implements Runnable {
|
|||||||
System.err.println("Unable to read message: " + e.getMessage());
|
System.err.println("Unable to read message: " + e.getMessage());
|
||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
continue;
|
continue;
|
||||||
}/*
|
}
|
||||||
|
|
||||||
//Add it to message queue.
|
|
||||||
this.messagesReceivedQueue.add(message);*/
|
|
||||||
|
|
||||||
|
|
||||||
//Checks which message is being received and does what is needed for that message.
|
//Checks which message is being received and does what is needed for that message.
|
||||||
//Heartbeat.
|
//Heartbeat.
|
||||||
|
|||||||
Reference in New Issue
Block a user