mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 12:03:58 +00:00
Merge branch 'master' into racecommittee_integrated
Conflicts: java/com.sap.sailing.domain.tractracadapter/src/com/sap/sailing/domain/tractracadapter/DomainFactory.java
This commit is contained in:
commit
44da6d19b3
7 files changed
+71
-63
No files matched your search
@@ -0,0 +1 @@
|
||||
bin
|
||||
+6
-6
@@ -163,14 +163,14 @@ public interface DomainFactory {
|
||||
* if <code>null</code>, all stored data until the "end of time" will be loaded that the event has to
|
||||
* provide, particularly for the mark positions which are stored per event, not per race; otherwise,
|
||||
* particularly the mark position loading will be constrained to this end time.
|
||||
* @param simulator TODO
|
||||
* @param tokenToRetrieveAssociatedRace
|
||||
* used to update the set of{@link RaceDefinition}s received by the
|
||||
* {@link RaceCourseReceiver} created by this call
|
||||
*/
|
||||
Iterable<Receiver> getUpdateReceivers(DynamicTrackedRegatta trackedRegatta, Event tractracEvent, TimePoint startOfTracking,
|
||||
TimePoint endOfTracking, long delayToLiveInMillis, Simulator simulator, WindStore windStore, DynamicRaceDefinitionSet raceDefinitionSetToUpdate, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceCommitteeStore raceCommitteeStore);
|
||||
*/
|
||||
Iterable<Receiver> getUpdateReceivers(DynamicTrackedRegatta trackedRegatta, Event tractracEvent,
|
||||
TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis, Simulator simulator,
|
||||
WindStore windStore, DynamicRaceDefinitionSet raceDefinitionSetToUpdate,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceCommitteeStore raceCommitteeStore);
|
||||
|
||||
/**
|
||||
* Creates a {@link RaceDefinition} from a TracTrac {@link Race} and a domain {@link Course} definition. The
|
||||
@@ -220,7 +220,7 @@ public interface DomainFactory {
|
||||
* of waypoints. The waypoints are created from the control points and represent usages of the control points
|
||||
* in a course. A single control point may be used more than once in a course's list of waypoints.
|
||||
*/
|
||||
void updateCourseWaypoints(Course courseToUpdate, Iterable<TracTracControlPoint> controlPoints) throws PatchFailedException;
|
||||
void updateCourseWaypoints(Course courseToUpdate, Iterable<? extends TracTracControlPoint> controlPoints) throws PatchFailedException;
|
||||
|
||||
TracTracConfiguration createTracTracConfiguration(String name, String jsonURL, String liveDataURI, String storedDataURI);
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.tractracadapter.impl;
|
||||
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracControlPoint;
|
||||
import com.sap.sailing.domain.common.WithID;
|
||||
|
||||
/**
|
||||
* Implements hash code and equality based on the control point's UUID.
|
||||
@@ -8,7 +8,7 @@ import com.sap.sailing.domain.tractracadapter.TracTracControlPoint;
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractTracTracControlPoint implements TracTracControlPoint {
|
||||
public abstract class AbstractWithID implements WithID {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -17,7 +17,7 @@ public abstract class AbstractTracTracControlPoint implements TracTracControlPoi
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return getId().equals(((TracTracControlPoint) obj).getId());
|
||||
return getId().equals(((WithID) obj).getId());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-12
@@ -21,7 +21,6 @@ import java.util.regex.Pattern;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.WithID;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracControlPoint;
|
||||
|
||||
@@ -92,7 +91,7 @@ public class ClientParamsPHP {
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
private abstract class ObjectWithUUID implements WithID {
|
||||
private abstract class ObjectWithUUID extends AbstractWithID {
|
||||
private final Pattern propertyNamePattern = Pattern.compile("([^0-9]*)(([0-9][0-9]*)(.*))?");
|
||||
private final String propertyNamePrefix;
|
||||
private final Integer number;
|
||||
@@ -119,16 +118,6 @@ public class ClientParamsPHP {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return getId().equals(((WithID) obj).getId());
|
||||
}
|
||||
|
||||
protected String getProperty(String propertyName) {
|
||||
String result = properties.get(propertyNamePrefix+number+propertyName);
|
||||
if (result != null) {
|
||||
|
||||
+2
-1
@@ -4,9 +4,10 @@ import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracControlPoint;
|
||||
import com.tractrac.clientmodule.ControlPoint;
|
||||
|
||||
public class ControlPointAdapter extends AbstractTracTracControlPoint {
|
||||
public class ControlPointAdapter extends AbstractWithID implements TracTracControlPoint {
|
||||
private final ControlPoint controlPoint;
|
||||
|
||||
public ControlPointAdapter(ControlPoint controlPoint) {
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCourseWaypoints(Course courseToUpdate, Iterable<TracTracControlPoint> controlPoints) throws PatchFailedException {
|
||||
public void updateCourseWaypoints(Course courseToUpdate, Iterable<? extends TracTracControlPoint> controlPoints) throws PatchFailedException {
|
||||
List<com.sap.sailing.domain.base.ControlPoint> newDomainControlPoints = new ArrayList<com.sap.sailing.domain.base.ControlPoint>();
|
||||
for (TracTracControlPoint tractracControlPoint : controlPoints) {
|
||||
com.sap.sailing.domain.base.ControlPoint newDomainControlPoint = getOrCreateControlPoint(tractracControlPoint);
|
||||
|
||||
+57
-40
@@ -56,6 +56,8 @@ import com.tractrac.clientmodule.data.DataController;
|
||||
import com.tractrac.clientmodule.data.DataController.Listener;
|
||||
import com.tractrac.clientmodule.setup.KeyValue;
|
||||
|
||||
import difflib.PatchFailedException;
|
||||
|
||||
public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements Listener, TracTracRaceTracker, DynamicRaceDefinitionSet {
|
||||
private static final Logger logger = Logger.getLogger(TracTracRaceTrackerImpl.class.getName());
|
||||
|
||||
@@ -173,7 +175,7 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
|
||||
simulator = null;
|
||||
}
|
||||
// Read event data from configuration file
|
||||
controlPointPositionPoller = scheduleControlPointPositionPoller(paramURL, simulator);
|
||||
controlPointPositionPoller = scheduleClientParamsPHPPoller(paramURL, simulator);
|
||||
// can happen that TracTrac event is null (occurs when there is no Internet connection)
|
||||
// so lets raise some meaningful exception
|
||||
if (tractracEvent == null) {
|
||||
@@ -235,52 +237,66 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
|
||||
* clientparams document
|
||||
* @return the task to cancel in case the tracker wants to terminate the poller
|
||||
*/
|
||||
private ScheduledFuture<?> scheduleControlPointPositionPoller(final URL paramURL, final Simulator simulator) {
|
||||
private ScheduledFuture<?> scheduleClientParamsPHPPoller(final URL paramURL, final Simulator simulator) {
|
||||
ScheduledFuture<?> task = scheduler.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override public void run() {
|
||||
Set<RaceDefinition> raceDefinitions = getRaces();
|
||||
if (raceDefinitions != null && !raceDefinitions.isEmpty()) {
|
||||
logger.info("fetching paramURL "+paramURL+" to check for updates for race(s) "+getRaces());
|
||||
ClientParamsPHP clientParams;
|
||||
try {
|
||||
clientParams = new ClientParamsPHP(new InputStreamReader(paramURL.openStream()));
|
||||
Iterable<? extends TracTracControlPoint> newCourseControlPoints = clientParams.getRaceDefaultRoute().getControlPoints();
|
||||
List<com.sap.sailing.domain.base.ControlPoint> currentCourseControlPoints = new ArrayList<>();
|
||||
for (Waypoint waypoint : getRaces().iterator().next().getCourse().getWaypoints()) {
|
||||
currentCourseControlPoints.add(waypoint.getControlPoint());
|
||||
}
|
||||
if (!newCourseControlPoints.equals(currentCourseControlPoints)) {
|
||||
logger.info("Detected course change based on clientparams.php contents for races "+getRaces());
|
||||
// TODO see bug 1014: update course from clientParams if a change is detected; may be used also for initial course definition
|
||||
}
|
||||
updateStartStopTimesAndLiveDelay(clientParams, simulator);
|
||||
for (TracTracControlPoint controlPoint : clientParams.getControlPointList()) {
|
||||
com.sap.sailing.domain.base.ControlPoint domainControlPoint = domainFactory.getOrCreateControlPoint(controlPoint);
|
||||
boolean first = true;
|
||||
for (Mark mark : domainControlPoint.getMarks()) {
|
||||
for (RaceDefinition raceDefinition : raceDefinitions) {
|
||||
DynamicTrackedRace trackedRace = getTrackedRegatta().getExistingTrackedRace(raceDefinition);
|
||||
if (trackedRace != null) {
|
||||
DynamicGPSFixTrack<Mark, GPSFix> markTrack = trackedRace.getOrCreateTrack(mark);
|
||||
if (markTrack.getFirstRawFix() == null) {
|
||||
markTrack.addGPSFix(new GPSFixImpl(first ? controlPoint.getMark1Position()
|
||||
: controlPoint.getMark2Position(), MillisecondsTimePoint.now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.info("Exception "+e.getMessage()+" while trying to read clientparams.php for races "+getRaces());
|
||||
logger.throwing(TracTracRaceTracker.class.getName(), "scheduleControlPointPositionPoller.run", e);
|
||||
}
|
||||
}
|
||||
pollAndParseClientParamsPHP(paramURL, simulator);
|
||||
}
|
||||
}, /* initialDelay */ 30000, /* delay */ 15000, /* unit */ TimeUnit.MILLISECONDS);
|
||||
return task;
|
||||
}
|
||||
|
||||
private void pollAndParseClientParamsPHP(final URL paramURL, final Simulator simulator) {
|
||||
Set<RaceDefinition> raceDefinitions = getRaces();
|
||||
if (raceDefinitions != null && !raceDefinitions.isEmpty()) {
|
||||
logger.info("fetching paramURL "+paramURL+" to check for updates for race(s) "+getRaces());
|
||||
ClientParamsPHP clientParams;
|
||||
try {
|
||||
clientParams = new ClientParamsPHP(new InputStreamReader(paramURL.openStream()));
|
||||
List<com.sap.sailing.domain.base.ControlPoint> newCourseControlPoints = new ArrayList<>();
|
||||
final Iterable<? extends TracTracControlPoint> newTracTracControlPoints = clientParams.getRaceDefaultRoute().getControlPoints();
|
||||
for (TracTracControlPoint newTracTracControlPoint : newTracTracControlPoints) {
|
||||
newCourseControlPoints.add(domainFactory.getOrCreateControlPoint(newTracTracControlPoint));
|
||||
}
|
||||
List<com.sap.sailing.domain.base.ControlPoint> currentCourseControlPoints = new ArrayList<>();
|
||||
final Course course = getRaces().iterator().next().getCourse();
|
||||
for (Waypoint waypoint : course.getWaypoints()) {
|
||||
currentCourseControlPoints.add(waypoint.getControlPoint());
|
||||
}
|
||||
if (!newCourseControlPoints.equals(currentCourseControlPoints)) {
|
||||
logger.info("Detected course change based on clientparams.php contents for races "+getRaces());
|
||||
try {
|
||||
course.update(newCourseControlPoints, domainFactory.getBaseDomainFactory());
|
||||
} catch (PatchFailedException pfe) {
|
||||
logger.severe("Failed to apply course update "+newTracTracControlPoints+" to course "+course);
|
||||
logger.throwing(TracTracRaceTrackerImpl.class.getName(), "scheduleClientParamsPHPPoller.run", pfe);
|
||||
}
|
||||
}
|
||||
updateStartStopTimesAndLiveDelay(clientParams, simulator);
|
||||
for (TracTracControlPoint controlPoint : clientParams.getControlPointList()) {
|
||||
com.sap.sailing.domain.base.ControlPoint domainControlPoint = domainFactory.getOrCreateControlPoint(controlPoint);
|
||||
boolean first = true;
|
||||
for (Mark mark : domainControlPoint.getMarks()) {
|
||||
for (RaceDefinition raceDefinition : raceDefinitions) {
|
||||
DynamicTrackedRace trackedRace = getTrackedRegatta().getExistingTrackedRace(raceDefinition);
|
||||
if (trackedRace != null) {
|
||||
DynamicGPSFixTrack<Mark, GPSFix> markTrack = trackedRace.getOrCreateTrack(mark);
|
||||
if (markTrack.getFirstRawFix() == null) {
|
||||
markTrack.addGPSFix(new GPSFixImpl(first ? controlPoint.getMark1Position()
|
||||
: controlPoint.getMark2Position(), MillisecondsTimePoint.now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.info("Exception "+e.getMessage()+" while trying to read clientparams.php for races "+getRaces());
|
||||
logger.throwing(TracTracRaceTracker.class.getName(), "scheduleClientParamsPHPPoller.run", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStartStopTimesAndLiveDelay(ClientParamsPHP clientParams, Simulator simulator) {
|
||||
RaceDefinition currentRace = null;
|
||||
long delayInMillis = clientParams.getLiveDelayInMillis();
|
||||
@@ -421,4 +437,5 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
|
||||
public void addRaceDefinition(RaceDefinition race) {
|
||||
races.add(race);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user