mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Began figuring out how to implement XML data in place of mock data.
#story[820] #pair[ajm412, wmu16]
This commit is contained in:
@@ -18,12 +18,11 @@ import seng302.models.Yacht;
|
|||||||
import seng302.models.parsers.StreamParser;
|
import seng302.models.parsers.StreamParser;
|
||||||
import seng302.models.parsers.XMLParser;
|
import seng302.models.parsers.XMLParser;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.util.ResourceBundle;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.Timer;
|
||||||
import java.util.*;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class Controller implements Initializable {
|
public class Controller implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
@@ -65,9 +64,9 @@ public class Controller implements Initializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
//DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
//format.setTimeZone(TimeZone.getTimeZone("GMT-8"));
|
||||||
realTime.setText(format.format(System.currentTimeMillis()));
|
//realTime.setText(format.format(new Date()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -165,6 +165,22 @@ public class StreamParser extends Thread{
|
|||||||
long heartbeat = bytesToLong(packet.getPayload());
|
long heartbeat = bytesToLong(packet.getPayload());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getTimeZoneString() {
|
||||||
|
|
||||||
|
Integer offset = xmlObject.getRegattaXML().getUtcOffset();
|
||||||
|
StringBuilder utcOffset = new StringBuilder();
|
||||||
|
utcOffset.append("GMT");
|
||||||
|
if (offset > 0) {
|
||||||
|
utcOffset.append("+");
|
||||||
|
utcOffset.append(offset);
|
||||||
|
} else if (offset < 0) {
|
||||||
|
utcOffset.append("-");
|
||||||
|
utcOffset.append(offset);
|
||||||
|
}
|
||||||
|
return utcOffset.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the useful race status data from race status type packets. This method will also print to the
|
* Extracts the useful race status data from race status type packets. This method will also print to the
|
||||||
* console the current state of the race (if it has started/finished or is about to start), along side
|
* console the current state of the race (if it has started/finished or is about to start), along side
|
||||||
@@ -180,10 +196,15 @@ public class StreamParser extends Thread{
|
|||||||
int raceStatus = payload[11];
|
int raceStatus = payload[11];
|
||||||
// System.out.println("raceStatus = " + raceStatus);
|
// System.out.println("raceStatus = " + raceStatus);
|
||||||
long expectedStartTime = bytesToLong(Arrays.copyOfRange(payload,12,18));
|
long expectedStartTime = bytesToLong(Arrays.copyOfRange(payload,12,18));
|
||||||
|
|
||||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
if (xmlObject.getRegattaXML() != null) {
|
||||||
|
format.setTimeZone(TimeZone.getTimeZone(getTimeZoneString()));
|
||||||
|
currentTimeString = format.format((new Date (currentTime)).getTime());
|
||||||
|
}
|
||||||
long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000;
|
long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000;
|
||||||
currentTimeString = format.format((new Date (currentTime)).getTime());
|
|
||||||
|
|
||||||
if (timeTillStart > 0) {
|
if (timeTillStart > 0) {
|
||||||
timeSinceStart = timeTillStart;
|
timeSinceStart = timeTillStart;
|
||||||
//System.out.println("Time till start: " + timeTillStart + " Seconds");
|
//System.out.println("Time till start: " + timeTillStart + " Seconds");
|
||||||
|
|||||||
Reference in New Issue
Block a user