mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 23:00:59 +00:00
Implemented calculation of more data for live races
This commit is contained in:
1 parent
9204f80a5e
commit
b4d6dfd1f8
5 files changed
+78
-48
No files matched your search
+4
-19
@@ -1,22 +1,18 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.ReadonlyRaceState;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.impl.ReadonlyRaceStateImpl;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.Leg;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.Action;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.RacesActionUtil.RaceCallback;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class GetLiveRacesAction implements Action<ResultWithTTL<LiveRacesDTO>> {
|
||||
private UUID eventId;
|
||||
@@ -55,7 +51,6 @@ public class GetLiveRacesAction implements Action<ResultWithTTL<LiveRacesDTO>> {
|
||||
// // race isn't live
|
||||
// return;
|
||||
// }
|
||||
TrackedRace trackedRace = rc.trackedRace;
|
||||
|
||||
TimePoint startTime = state.getStartTime();
|
||||
if(startTime == null) {
|
||||
@@ -68,20 +63,10 @@ public class GetLiveRacesAction implements Action<ResultWithTTL<LiveRacesDTO>> {
|
||||
liveRaceDTO.setRaceName(rc.raceColumn.getName());
|
||||
liveRaceDTO.setStart(startTime.asDate());
|
||||
liveRaceDTO.setBoatClass(rc.getBoatClassName());
|
||||
|
||||
Course course = raceDefinition.getCourse();
|
||||
if(course != null) {
|
||||
liveRaceDTO.setCourseArea(course.getName());
|
||||
}
|
||||
|
||||
liveRaceDTO.setCourseArea(rc.getCourseArea());
|
||||
liveRaceDTO.setCourse(rc.getCourseName());
|
||||
liveRaceDTO.setFlagState(rc.getFlagStateOrNull());
|
||||
|
||||
List<Leg> legs = state.getCourseDesign() != null ? state.getCourseDesign().getLegs() : (raceDefinition.getCourse() != null ? raceDefinition.getCourse().getLegs() : null);
|
||||
if(legs != null && trackedRace != null) {
|
||||
liveRaceDTO.setTotalLegs(legs.size());
|
||||
liveRaceDTO.setCurrentLeg(trackedRace.getLastLegStarted(MillisecondsTimePoint.now()));
|
||||
}
|
||||
|
||||
liveRaceDTO.setProgress(rc.getProgressOrNull());
|
||||
liveRaceDTO.setWind(rc.getWindOrNull());
|
||||
|
||||
result.addRace(liveRaceDTO);
|
||||
|
||||
+11
-29
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.ui.shared.race.FlagStateDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.RaceMetadataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.RaceProgressDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.SimpleWindDTO;
|
||||
|
||||
public class LiveRaceDTO extends RaceMetadataDTO {
|
||||
@@ -11,12 +12,9 @@ public class LiveRaceDTO extends RaceMetadataDTO {
|
||||
|
||||
private SimpleWindDTO wind;
|
||||
|
||||
private int course;
|
||||
|
||||
private Integer totalLegs;
|
||||
private Integer currentLeg;
|
||||
|
||||
private String boatClass;
|
||||
|
||||
private RaceProgressDTO progress;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private LiveRaceDTO() {
|
||||
@@ -34,30 +32,6 @@ public class LiveRaceDTO extends RaceMetadataDTO {
|
||||
this.wind = wind;
|
||||
}
|
||||
|
||||
public int getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(int course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public Integer getTotalLegs() {
|
||||
return totalLegs;
|
||||
}
|
||||
|
||||
public void setTotalLegs(Integer totalLegs) {
|
||||
this.totalLegs = totalLegs;
|
||||
}
|
||||
|
||||
public Integer getCurrentLeg() {
|
||||
return currentLeg;
|
||||
}
|
||||
|
||||
public void setCurrentLeg(Integer currentLeg) {
|
||||
this.currentLeg = currentLeg;
|
||||
}
|
||||
|
||||
public FlagStateDTO getFlagState() {
|
||||
return flagState;
|
||||
}
|
||||
@@ -73,4 +47,12 @@ public class LiveRaceDTO extends RaceMetadataDTO {
|
||||
public void setBoatClass(String boatClass) {
|
||||
this.boatClass = boatClass;
|
||||
}
|
||||
|
||||
public RaceProgressDTO getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(RaceProgressDTO progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
}
|
||||
+28
@@ -8,7 +8,9 @@ import com.sap.sailing.domain.abstractlog.race.state.ReadonlyRaceState;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.impl.ReadonlyRaceStateImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.FlagPoleState;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.Leg;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
@@ -28,6 +30,7 @@ import com.sap.sailing.domain.tracking.WindTrack;
|
||||
import com.sap.sailing.domain.tracking.WindWithConfidence;
|
||||
import com.sap.sailing.gwt.ui.shared.race.FlagStateDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.FleetMetadataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.RaceProgressDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.SimpleWindDTO;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
@@ -162,4 +165,29 @@ public class RaceContext {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCourseArea() {
|
||||
Regatta regatta = getRegatta();
|
||||
if(regatta != null && regatta.getDefaultCourseArea() != null) {
|
||||
return regatta.getDefaultCourseArea().getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RaceProgressDTO getProgressOrNull() {
|
||||
ReadonlyRaceState state = getRaceState();
|
||||
List<Leg> legs = state.getCourseDesign() != null ? state.getCourseDesign().getLegs() : (raceDefinition.getCourse() != null ? raceDefinition.getCourse().getLegs() : null);
|
||||
if(legs != null && trackedRace != null) {
|
||||
return new RaceProgressDTO(trackedRace.getLastLegStarted(MillisecondsTimePoint.now()), legs.size());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCourseName() {
|
||||
Course course = raceDefinition.getCourse();
|
||||
if(course != null) {
|
||||
return course.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+9
@@ -14,6 +14,7 @@ public class RaceMetadataDTO implements IsSerializable {
|
||||
private FleetMetadataDTO fleet;
|
||||
private Date start;
|
||||
private String courseArea;
|
||||
private String course;
|
||||
|
||||
protected RaceMetadataDTO() {
|
||||
}
|
||||
@@ -65,4 +66,12 @@ public class RaceMetadataDTO implements IsSerializable {
|
||||
public void setCourseArea(String courseArea) {
|
||||
this.courseArea = courseArea;
|
||||
}
|
||||
|
||||
public String getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(String course) {
|
||||
this.course = course;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.sap.sailing.gwt.ui.shared.race;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class RaceProgressDTO implements IsSerializable {
|
||||
private Integer currentLeg;
|
||||
private Integer totalLegs;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private RaceProgressDTO() {
|
||||
}
|
||||
|
||||
public RaceProgressDTO(Integer currentLeg, Integer totalLegs) {
|
||||
super();
|
||||
this.currentLeg = currentLeg;
|
||||
this.totalLegs = totalLegs;
|
||||
}
|
||||
|
||||
public Integer getCurrentLeg() {
|
||||
return currentLeg;
|
||||
}
|
||||
|
||||
public Integer getTotalLegs() {
|
||||
return totalLegs;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user