diff --git a/src/main/java/telraam/App.java b/src/main/java/telraam/App.java index d7bfdba..5c93fe8 100644 --- a/src/main/java/telraam/App.java +++ b/src/main/java/telraam/App.java @@ -17,9 +17,9 @@ import telraam.database.daos.*; import telraam.database.models.Station; import telraam.healthchecks.TemplateHealthCheck; -import telraam.logic.Lapper; -import telraam.logic.external.ExternalLapper; -import telraam.logic.robust.RobustLapper; +import telraam.logic.lapper.Lapper; +import telraam.logic.lapper.external.ExternalLapper; +import telraam.logic.lapper.robust.RobustLapper; import telraam.station.Fetcher; import telraam.util.AcceptedLapsUtil; import telraam.websocket.WebSocketConnection; diff --git a/src/main/java/telraam/logic/lapper/Lapper.java b/src/main/java/telraam/logic/lapper/Lapper.java index c3dc674..d999307 100644 --- a/src/main/java/telraam/logic/lapper/Lapper.java +++ b/src/main/java/telraam/logic/lapper/Lapper.java @@ -1,4 +1,4 @@ -package telraam.logic; +package telraam.logic.lapper; import io.dropwizard.jersey.setup.JerseyEnvironment; import telraam.database.models.Detection; diff --git a/src/main/java/telraam/logic/lapper/external/ExternalLapper.java b/src/main/java/telraam/logic/lapper/external/ExternalLapper.java index 3aee9f2..510e28a 100644 --- a/src/main/java/telraam/logic/lapper/external/ExternalLapper.java +++ b/src/main/java/telraam/logic/lapper/external/ExternalLapper.java @@ -1,4 +1,4 @@ -package telraam.logic.external; +package telraam.logic.lapper.external; import io.dropwizard.jersey.setup.JerseyEnvironment; import org.jdbi.v3.core.Jdbi; @@ -7,8 +7,8 @@ import telraam.database.models.Detection; import telraam.database.models.Lap; import telraam.database.models.LapSource; -import telraam.logic.Lapper; -import telraam.logic.external.models.ExternalLapperTeamLaps; +import telraam.logic.lapper.Lapper; +import telraam.logic.lapper.external.models.ExternalLapperTeamLaps; import java.sql.Timestamp; import java.util.Comparator; diff --git a/src/main/java/telraam/logic/lapper/external/ExternalLapperResource.java b/src/main/java/telraam/logic/lapper/external/ExternalLapperResource.java index 37f8e58..55f6aa0 100644 --- a/src/main/java/telraam/logic/lapper/external/ExternalLapperResource.java +++ b/src/main/java/telraam/logic/lapper/external/ExternalLapperResource.java @@ -1,10 +1,10 @@ -package telraam.logic.external; +package telraam.logic.lapper.external; import io.swagger.v3.oas.annotations.Operation; import jakarta.ws.rs.*; import jakarta.ws.rs.core.MediaType; -import telraam.logic.external.models.ExternalLapperStats; -import telraam.logic.external.models.ExternalLapperTeamLaps; +import telraam.logic.lapper.external.models.ExternalLapperStats; +import telraam.logic.lapper.external.models.ExternalLapperTeamLaps; import java.util.List; diff --git a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperLap.java b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperLap.java index f343ce1..3623891 100644 --- a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperLap.java +++ b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperLap.java @@ -1,4 +1,4 @@ -package telraam.logic.external.models; +package telraam.logic.lapper.external.models; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperStats.java b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperStats.java index cc31a04..8c875bc 100644 --- a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperStats.java +++ b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperStats.java @@ -1,4 +1,4 @@ -package telraam.logic.external.models; +package telraam.logic.lapper.external.models; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperTeamLaps.java b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperTeamLaps.java index c8e8170..fa37f63 100644 --- a/src/main/java/telraam/logic/lapper/external/models/ExternalLapperTeamLaps.java +++ b/src/main/java/telraam/logic/lapper/external/models/ExternalLapperTeamLaps.java @@ -1,4 +1,4 @@ -package telraam.logic.external.models; +package telraam.logic.lapper.external.models; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/telraam/logic/lapper/robust/RobustLapper.java b/src/main/java/telraam/logic/lapper/robust/RobustLapper.java index 2ad64c5..62ae807 100644 --- a/src/main/java/telraam/logic/lapper/robust/RobustLapper.java +++ b/src/main/java/telraam/logic/lapper/robust/RobustLapper.java @@ -1,4 +1,4 @@ -package telraam.logic.robust; +package telraam.logic.lapper.robust; import io.dropwizard.jersey.setup.JerseyEnvironment; import org.jdbi.v3.core.Jdbi; @@ -10,7 +10,7 @@ import telraam.database.models.Lap; import telraam.database.models.LapSource; import telraam.database.models.Station; -import telraam.logic.Lapper; +import telraam.logic.lapper.Lapper; import java.sql.Timestamp; import java.util.*; diff --git a/src/main/java/telraam/logic/lapper/simple/SimpleLapper.java b/src/main/java/telraam/logic/lapper/simple/SimpleLapper.java index 9b26f9b..608e724 100644 --- a/src/main/java/telraam/logic/lapper/simple/SimpleLapper.java +++ b/src/main/java/telraam/logic/lapper/simple/SimpleLapper.java @@ -1,11 +1,11 @@ -package telraam.logic.simple; +package telraam.logic.lapper.simple; import io.dropwizard.jersey.setup.JerseyEnvironment; import org.jdbi.v3.core.Jdbi; import telraam.database.daos.LapDAO; import telraam.database.daos.LapSourceDAO; import telraam.database.models.*; -import telraam.logic.Lapper; +import telraam.logic.lapper.Lapper; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/telraam/logic/positioner/CircularQueue.java b/src/main/java/telraam/logic/positioner/CircularQueue.java index eb0c403..042ba79 100644 --- a/src/main/java/telraam/logic/positioner/CircularQueue.java +++ b/src/main/java/telraam/logic/positioner/CircularQueue.java @@ -1,4 +1,4 @@ -package telraam.logic.positioners; +package telraam.logic.positioner; import java.util.LinkedList; diff --git a/src/main/java/telraam/logic/positioner/Position.java b/src/main/java/telraam/logic/positioner/Position.java index 988120c..23bcf00 100644 --- a/src/main/java/telraam/logic/positioner/Position.java +++ b/src/main/java/telraam/logic/positioner/Position.java @@ -1,4 +1,29 @@ -package telraam.logic.positioner; +package telraam.logic.positioners; +import lombok.Getter; +import lombok.Setter; +import telraam.database.models.Team; +import telraam.websocket.WebSocketMessageSingleton; + +@Getter @Setter public class Position { + private Team team; + private float progress; // Progress of the lap. Between 0-1 + private float speed; // Current speed. Progress / second + + public Position(Team team) { + this.team = team; + this.progress = 0; + this.speed = 0; + } + + private String toWebsocketMessage() { + return String.format("{\"topic\": \"position\", \"data\": {\"team\": %d, \"progress\": %.4f, \"speed\": %.5f}}", team.getId(), this.progress, this.speed); + } + + public void send() { + WebSocketMessageSingleton.getInstance().sendToAll( + this.toWebsocketMessage() + ); + } } diff --git a/src/main/java/telraam/logic/positioner/SimplePositioner.java b/src/main/java/telraam/logic/positioner/SimplePositioner.java index 83d2872..794fa35 100644 --- a/src/main/java/telraam/logic/positioner/SimplePositioner.java +++ b/src/main/java/telraam/logic/positioner/SimplePositioner.java @@ -1,4 +1,4 @@ -package telraam.logic.positioners; +package telraam.logic.positioner; import org.jdbi.v3.core.Jdbi; import telraam.database.daos.BatonSwitchoverDAO; diff --git a/src/main/java/telraam/station/Fetcher.java b/src/main/java/telraam/station/Fetcher.java index 54e04db..d2cdce0 100644 --- a/src/main/java/telraam/station/Fetcher.java +++ b/src/main/java/telraam/station/Fetcher.java @@ -7,7 +7,7 @@ import telraam.database.models.Baton; import telraam.database.models.Detection; import telraam.database.models.Station; -import telraam.logic.Lapper; +import telraam.logic.lapper.Lapper; import telraam.station.models.RonnyDetection; import telraam.station.models.RonnyResponse; diff --git a/src/test/java/telraam/logic/simple/SimpleLapperTest.java b/src/test/java/telraam/logic/simple/SimpleLapperTest.java index 838397f..c50e810 100644 --- a/src/test/java/telraam/logic/simple/SimpleLapperTest.java +++ b/src/test/java/telraam/logic/simple/SimpleLapperTest.java @@ -8,8 +8,8 @@ import telraam.database.models.Detection; import telraam.database.models.Lap; import telraam.database.models.LapSource; -import telraam.logic.Lapper; -import telraam.logic.simple.SimpleLapper; +import telraam.logic.lapper.Lapper; +import telraam.logic.lapper.simple.SimpleLapper; import java.sql.Timestamp; import java.util.Optional;