Refactored Race, MockRace, and VisualiserRace to use RaceClock instead of keeping their own timers.

Moved FPS tracking to Race class, so both VisualiserRace and MockRace can monitor their FPS.
LatestMessages is now observable. It notifies observers when an XMLMessage is received.
Boat now has StringProperty for name and country/abbreviation.
Moved the MockRace timescale value to Constants.RaceTimeScale. This is passed in to MockRace on construction.
Tidied up StartController.
Copied the visualiser's resources into the resources folder.
Refactored RaceClock. Added comments. Tidied code a bit. Moved to shared.model.

Started work on RaceController.
This commit is contained in:
fjc40
2017-07-08 23:21:29 +12:00
parent f057ad58b7
commit abbbf70146
35 changed files with 2013 additions and 427 deletions
@@ -32,11 +32,11 @@ public class App extends Application {
@Override
public void start(Stage primaryStage) {
try {
Polars boatPolars = PolarParser.parse("polars/acc_polars.csv");
Polars boatPolars = PolarParser.parse("mock/polars/acc_polars.csv");
String regattaXML = readFile("mockXML/regattaTest.xml", StandardCharsets.UTF_8);
String raceXML = readFile("mockXML/raceTest.xml", StandardCharsets.UTF_8);
String boatXML = readFile("mockXML/boatTest.xml", StandardCharsets.UTF_8);
String regattaXML = readFile("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8);
String raceXML = readFile("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8);
String boatXML = readFile("mock/mockXML/boatTest.xml", StandardCharsets.UTF_8);
Event raceEvent = new Event(raceXML, regattaXML, boatXML, boatPolars);
raceEvent.start();
@@ -66,7 +66,7 @@ public class Event {
RegattaDataSource regattaDataSource = new RegattaXMLReader(this.regattaXML);
//Create and start race.
MockRace newRace = new MockRace(boatDataSource, raceDataSource, regattaDataSource, this.boatPolars, this.latestMessages);
MockRace newRace = new MockRace(boatDataSource, raceDataSource, regattaDataSource, this.latestMessages, this.boatPolars, Constants.RaceTimeScale);
new Thread(newRace).start();
@@ -97,6 +97,8 @@ public class Event {
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
long millisecondsToAdd = Constants.RacePreStartTime + (1 * 60 * 1000);
long secondsToAdd = millisecondsToAdd / 1000;
//Scale the time using our time scalar.
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
ZonedDateTime creationTime = ZonedDateTime.now();