Currently, mock/pom.xml and visualiser/pom.xml build racevisionGame mock and visualiser.

Now using jetbrains nullable/notnull instead of sun (was causing maven issues).
main
fjc40 9 years ago
parent cab9bf9574
commit 3a85fad211

@ -52,6 +52,12 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>seng302</groupId>
<artifactId>racevisionGame</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
@ -97,7 +103,7 @@
<transformer <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries> <manifestEntries>
<Main-Class>seng302.App</Main-Class> <Main-Class>mock.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>
@ -161,4 +167,4 @@
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>
</project> </project>

@ -14,12 +14,6 @@
<dependencies> <dependencies>
<dependency>
<groupId>seng302</groupId>
<artifactId>sharedModel</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

@ -39,17 +39,21 @@
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>15.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.geotools</groupId> <groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId> <artifactId>gt-referencing</artifactId>
<version>9.0</version> <version>9.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.bfsmith</groupId>
<artifactId>geotimezone</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies> </dependencies>
@ -78,40 +82,92 @@
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<build>
<plugins> <profiles>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <profile>
<artifactId>maven-compiler-plugin</artifactId> <id>mock</id>
<version>3.5.1</version>
</plugin> <build>
<plugin> <plugins>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-shade-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>2.4.3</version> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>3.5.1</version>
<transformers> </plugin>
<transformer <plugin>
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <groupId>org.apache.maven.plugins</groupId>
<manifestEntries> <artifactId>maven-shade-plugin</artifactId>
<Main-Class>seng302.App</Main-Class> <version>2.4.3</version>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK> <configuration>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK> <transformers>
</manifestEntries> <transformer
</transformer> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformers> <manifestEntries>
</configuration> <Main-Class>mock.app.App</Main-Class>
<executions> <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<execution> <X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<phase>package</phase> </manifestEntries>
<goals> </transformer>
<goal>shade</goal> </transformers>
</goals> </configuration>
</execution> <executions>
</executions> <execution>
</plugin> <phase>package</phase>
</plugins> <goals>
</build> <goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>visualiser</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>visualiser.app.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
</manifestEntries>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting> <reporting>
<plugins> <plugins>
<plugin> <plugin>

@ -1,9 +1,9 @@
package shared.model; package shared.model;
import com.sun.istack.internal.Nullable;
import javafx.beans.property.*; import javafx.beans.property.*;
import network.Messages.Enums.BoatStatusEnum; import network.Messages.Enums.BoatStatusEnum;
import org.jetbrains.annotations.Nullable;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;

@ -33,7 +33,7 @@ public class Constants {
* Frame periods are multiplied by this to get the amount of time a single frame represents. * Frame periods are multiplied by this to get the amount of time a single frame represents.
* E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred. * E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred.
*/ */
public static final int RaceTimeScale = 15; public static final int RaceTimeScale = 10;
/** /**
* The race pre-start time, in milliseconds. 3 minutes. * The race pre-start time, in milliseconds. 3 minutes.

@ -1,14 +1,11 @@
package shared.model; package shared.model;
import com.github.bfsmith.geotimezone.TimeZoneLookup;
import com.github.bfsmith.geotimezone.TimeZoneResult;
import com.sun.istack.internal.Nullable;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import org.jetbrains.annotations.Nullable;
import visualiser.model.ResizableRaceCanvas; import visualiser.model.ResizableRaceCanvas;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -91,20 +88,6 @@ public class RaceClock {
} }
//TODO could potentially remove this, and the dependency, as it doesn't appear to be needed (regatta.xml has timezone already).
/**
* Returns the ZonedDateTime corresponding to a specified GPSCoordinate.
* @param gpsCoordinate The GPSCoordinate to lookup.
* @return The ZonedDateTime for the coordinate.
*/
public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) {
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());
ZoneId zone = ZoneId.of(timeZoneResult.getResult());
return LocalDateTime.now(zone).atZone(zone);
}
/** /**
@ -227,6 +210,7 @@ public class RaceClock {
* Returns the current time of the race. * Returns the current time of the race.
* @return The current time of the race. * @return The current time of the race.
*/ */
@Nullable
public ZonedDateTime getCurrentTime() { public ZonedDateTime getCurrentTime() {
return currentTime; return currentTime;
} }

@ -104,19 +104,18 @@ public class VisualiserBoat extends Boat {
/** /**
* Attempts to add a new point to boat's track. * Attempts to add a new point to boat's track.
* It only adds a new point if the boat is still racing (see {@link #getStatus()} and {@link BoatStatusEnum#RACING}), and if at least {@link #trackPointTimeInterval} milliseconds have occurred. * It only adds a new point if the boat is still racing (see {@link #getStatus()} and {@link BoatStatusEnum#RACING}), and if at least {@link #trackPointTimeInterval} milliseconds have occurred, using race time.
* @param coordinate The {@link GPSCoordinate} of the trackpoint. * @param coordinate The {@link GPSCoordinate} of the trackpoint.
* @param currentTime The current race time.
* @see TrackPoint * @see TrackPoint
*/ */
public void addTrackPoint(GPSCoordinate coordinate) { public void addTrackPoint(GPSCoordinate coordinate, ZonedDateTime currentTime) {
//TODO bugfix: instead of creating a track point every #trackPointTimeInterval milliseconds of real time, we should base it off of race time, so that we will create a consistent number of track points regardless of what the race time scale is.
//Get current time. //Get current time.
long currentTime = System.currentTimeMillis(); long currentTimeMilli = currentTime.toInstant().toEpochMilli();
//Check if enough time has passed to create a new track point. //Check if enough time has passed to create a new track point.
Boolean canBeAdded = currentTime >= nextValidTime; Boolean canBeAdded = currentTimeMilli >= nextValidTime;
//If it has, and if we are still racing, create the point. //If it has, and if we are still racing, create the point.
if (canBeAdded && (getStatus() == BoatStatusEnum.RACING)) { if (canBeAdded && (getStatus() == BoatStatusEnum.RACING)) {
@ -125,11 +124,11 @@ public class VisualiserBoat extends Boat {
long expiryPeriod = trackPointTimeInterval * trackPointLimit; long expiryPeriod = trackPointTimeInterval * trackPointLimit;
//Create and add point. //Create and add point.
TrackPoint trackPoint = new TrackPoint(coordinate, currentTime, expiryPeriod); TrackPoint trackPoint = new TrackPoint(coordinate, currentTimeMilli, expiryPeriod);
track.add(trackPoint); track.add(trackPoint);
//Update the nextValidTime for the next track point. //Update the nextValidTime for the next track point.
nextValidTime = currentTime + trackPointTimeInterval; nextValidTime = currentTimeMilli + trackPointTimeInterval;
} }
} }

@ -237,7 +237,7 @@ public class VisualiserRace extends Race {
//Attempt to add a track point. //Attempt to add a track point.
if (newBoatStatusEnum == BoatStatusEnum.RACING) { if (newBoatStatusEnum == BoatStatusEnum.RACING) {
boat.addTrackPoint(boat.getCurrentPosition()); boat.addTrackPoint(boat.getCurrentPosition(), raceClock.getCurrentTime());
} }
//Set finish time if boat finished. //Set finish time if boat finished.
@ -353,17 +353,21 @@ public class VisualiserRace extends Race {
long currentFrameTime = System.currentTimeMillis(); long currentFrameTime = System.currentTimeMillis();
long framePeriod = currentFrameTime - lastFrameTime; long framePeriod = currentFrameTime - lastFrameTime;
//Update race status.
updateRaceStatus(latestMessages.getRaceStatus());
//Update racing boats. //Update racing boats.
updateBoats(boats, latestMessages.getBoatLocationMap(), latestMessages.getBoatStatusMap()); updateBoats(boats, latestMessages.getBoatLocationMap(), latestMessages.getBoatStatusMap());
//And their positions (e.g., 5th). //And their positions (e.g., 5th).
updateBoatPositions(boats); updateBoatPositions(boats);
//Update marker boats. //Update marker boats.
updateMarkers(boatMarkers, latestMessages.getBoatLocationMap(), latestMessages.getBoatStatusMap()); updateMarkers(boatMarkers, latestMessages.getBoatLocationMap(), latestMessages.getBoatStatusMap());
//Update race status.
updateRaceStatus(latestMessages.getRaceStatus());
if (getRaceStatusEnum() == RaceStatusEnum.FINISHED) { if (getRaceStatusEnum() == RaceStatusEnum.FINISHED) {

@ -54,6 +54,12 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>seng302</groupId>
<artifactId>racevisionGame</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
@ -99,7 +105,7 @@
<transformer <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries> <manifestEntries>
<Main-Class>seng302.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>
@ -163,4 +169,4 @@
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>
</project> </project>

Loading…
Cancel
Save