Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Mar 29, 2024
1 parent c4abdd9 commit 2a9cd40
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/main/java/telraam/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/telraam/logic/lapper/Lapper.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic;
package telraam.logic.lapper;

import io.dropwizard.jersey.setup.JerseyEnvironment;
import telraam.database.models.Detection;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic.external.models;
package telraam.logic.lapper.external.models;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic.external.models;
package telraam.logic.lapper.external.models;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic.external.models;
package telraam.logic.lapper.external.models;

import lombok.Getter;
import lombok.Setter;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/telraam/logic/lapper/robust/RobustLapper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.*;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/telraam/logic/lapper/simple/SimpleLapper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/telraam/logic/positioner/CircularQueue.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic.positioners;
package telraam.logic.positioner;

import java.util.LinkedList;

Expand Down
27 changes: 26 additions & 1 deletion src/main/java/telraam/logic/positioner/Position.java
Original file line number Diff line number Diff line change
@@ -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()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telraam.logic.positioners;
package telraam.logic.positioner;

import org.jdbi.v3.core.Jdbi;
import telraam.database.daos.BatonSwitchoverDAO;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/telraam/station/Fetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/telraam/logic/simple/SimpleLapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2a9cd40

Please sign in to comment.