moved Pair and Triple from com.sap.sailing.common.Util to com.sap.sse.common.Util and introduced all missing dependencies on com.sap.sse.common

This commit is contained in:
Axel Uhl
2014-06-02 23:31:26 +02:00
parent c4cea6660d
commit 0c47e86304
334 changed files with 1540 additions and 1692 deletions
@@ -11,7 +11,6 @@ import java.util.logging.Logger;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.igtimiadapter.Account;
import com.sap.sailing.domain.igtimiadapter.IgtimiConnection;
import com.sap.sailing.domain.igtimiadapter.IgtimiConnectionFactory;
@@ -20,12 +19,13 @@ import com.sap.sailing.domain.igtimiadapter.shared.IgtimiWindReceiver;
import com.sap.sailing.domain.tracking.AbstractWindTracker;
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
import com.sap.sailing.domain.tracking.WindTracker;
import com.sap.sse.common.Util;
public class IgtimiWindTracker extends AbstractWindTracker implements WindTracker {
private static final Logger logger = Logger.getLogger(IgtimiWindTracker.class.getName());
private static final int TIME_INTERVAL_TO_TRACK_BEFORE_RACE_START_MILLIS = 10*60*1000; // 10 minutes
private static final long TIME_INTERVAL_TO_TRACK_AFTER_END_OF_RACE_MILLIS = 60*60*1000; // 60 minutes
private final Map<LiveDataConnection, Pair<Iterable<String>, Account>> liveConnectionsAndDeviceSerialNumber;
private final Map<LiveDataConnection, Util.Pair<Iterable<String>, Account>> liveConnectionsAndDeviceSerialNumber;
private final IgtimiWindTrackerFactory windTrackerFactory;
private boolean stopping;
@@ -50,7 +50,7 @@ public class IgtimiWindTracker extends AbstractWindTracker implements WindTracke
IgtimiWindReceiver windReceiver = new IgtimiWindReceiver(devicesWeShouldListenTo);
liveConnection.addListener(windReceiver);
windReceiver.addListener(new WindListenerSendingToTrackedRace(Collections.singleton(getTrackedRace()), windTrackerFactory));
liveConnectionsAndDeviceSerialNumber.put(liveConnection, new Pair<Iterable<String>, Account>(devicesWeShouldListenTo, account));
liveConnectionsAndDeviceSerialNumber.put(liveConnection, new Util.Pair<Iterable<String>, Account>(devicesWeShouldListenTo, account));
}
}
} catch (Exception e) {
@@ -114,7 +114,7 @@ public class IgtimiWindTracker extends AbstractWindTracker implements WindTracke
logger.info("Stopping Igtimi live connection "+ldc);
ldc.stop();
} catch (Exception e) {
final Pair<Iterable<String>, Account> deviceSerialNumberAndAccount = liveConnectionsAndDeviceSerialNumber.get(ldc);
final Util.Pair<Iterable<String>, Account> deviceSerialNumberAndAccount = liveConnectionsAndDeviceSerialNumber.get(ldc);
logger.log(Level.INFO,
"Exception trying to stop Igtimi live connection for wind receiver for race "
+ getTrackedRace().getRace() + " and device " + deviceSerialNumberAndAccount.getA()
@@ -20,7 +20,6 @@ import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
import com.sap.sailing.domain.common.impl.Util;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.common.scalablevalue.ScalableValue;
import com.sap.sailing.domain.common.scalablevalue.impl.ScalableBearing;
import com.sap.sailing.domain.common.scalablevalue.impl.ScalablePosition;
@@ -180,14 +179,14 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
private Wind getWind(final TimePoint timePoint, String deviceSerialNumber) throws ClassNotFoundException, IOException, ParseException {
final Wind result;
Pair<AWA, AWA> awaPair = getSurroundingFixes(getAwaTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<AWA, AWA> awaPair = getSurroundingFixes(getAwaTrack(deviceSerialNumber), timePoint);
Bearing awa = getAWA(timePoint, awaPair);
Pair<AWS, AWS> awsPair = getSurroundingFixes(getAwsTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<AWS, AWS> awsPair = getSurroundingFixes(getAwsTrack(deviceSerialNumber), timePoint);
Speed aws = getAWS(timePoint, awsPair);
Pair<GpsLatLong, GpsLatLong> gpsPair = getSurroundingFixes(getGpsTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<GpsLatLong, GpsLatLong> gpsPair = getSurroundingFixes(getGpsTrack(deviceSerialNumber), timePoint);
Position pos = getPosition(timePoint, gpsPair);
Pair<HDG, HDG> hdgPair = getSurroundingFixes(getHdgTrack(deviceSerialNumber), timePoint);
Pair<HDGM, HDGM> hdgmPair = getSurroundingFixes(getHdgmTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<HDG, HDG> hdgPair = getSurroundingFixes(getHdgTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<HDGM, HDGM> hdgmPair = getSurroundingFixes(getHdgmTrack(deviceSerialNumber), timePoint);
Bearing heading = getHeading(timePoint, hdgPair, hdgmPair, pos);
if (awa != null && aws != null && pos != null && heading != null) {
Bearing apparentWindDirection = heading.add(awa);
@@ -215,9 +214,9 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
* So again, my personal preference would be to work with the data that should be the most accurate
* (COG/SOG) and consider algorithms that handle smoothing of that data best."
*/
Pair<SOG, SOG> sogPair = getSurroundingFixes(getSogTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<SOG, SOG> sogPair = getSurroundingFixes(getSogTrack(deviceSerialNumber), timePoint);
Speed sog = getSOG(timePoint, sogPair);
Pair<COG, COG> cogPair = getSurroundingFixes(getCogTrack(deviceSerialNumber), timePoint);
com.sap.sse.common.Util.Pair<COG, COG> cogPair = getSurroundingFixes(getCogTrack(deviceSerialNumber), timePoint);
Bearing cog = getCOG(timePoint, cogPair);
SpeedWithBearing sogCog = new KnotSpeedWithBearingImpl(sog.getKnots(), cog);
SpeedWithBearing trueWindSpeedAndDirection = apparentWindSpeedWithDirection.add(sogCog);
@@ -228,7 +227,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return result;
}
private Bearing getAWA(TimePoint timePoint, Pair<AWA, AWA> awaPair) {
private Bearing getAWA(TimePoint timePoint, com.sap.sse.common.Util.Pair<AWA, AWA> awaPair) {
final Bearing awaFrom;
if (awaPair.getA() == null) {
if (awaPair.getB() == null) {
@@ -248,7 +247,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return awaFrom == null ? null : awaFrom.reverse();
}
private Speed getAWS(TimePoint timePoint, Pair<AWS, AWS> awsPair) {
private Speed getAWS(TimePoint timePoint, com.sap.sse.common.Util.Pair<AWS, AWS> awsPair) {
final Speed aws;
if (awsPair.getA() == null) {
if (awsPair.getB() == null) {
@@ -268,7 +267,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return aws;
}
private Speed getSOG(TimePoint timePoint, Pair<SOG, SOG> sogPair) {
private Speed getSOG(TimePoint timePoint, com.sap.sse.common.Util.Pair<SOG, SOG> sogPair) {
final Speed sog;
if (sogPair.getA() == null) {
if (sogPair.getB() == null) {
@@ -288,7 +287,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return sog;
}
private Bearing getCOG(TimePoint timePoint, Pair<COG, COG> cogPair) {
private Bearing getCOG(TimePoint timePoint, com.sap.sse.common.Util.Pair<COG, COG> cogPair) {
final Bearing sog;
if (cogPair.getA() == null) {
if (cogPair.getB() == null) {
@@ -308,7 +307,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return sog;
}
private Position getPosition(TimePoint timePoint, Pair<GpsLatLong, GpsLatLong> gpsPair) {
private Position getPosition(TimePoint timePoint, com.sap.sse.common.Util.Pair<GpsLatLong, GpsLatLong> gpsPair) {
final Position pos;
if (gpsPair.getA() == null) {
if (gpsPair.getB() == null) {
@@ -328,7 +327,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return pos;
}
private Bearing getHDG(TimePoint timePoint, Pair<HDG, HDG> hdgPair) {
private Bearing getHDG(TimePoint timePoint, com.sap.sse.common.Util.Pair<HDG, HDG> hdgPair) {
final Bearing hdg;
if (hdgPair.getA() == null) {
if (hdgPair.getB() == null) {
@@ -348,7 +347,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return hdg;
}
private Bearing getHDGM(TimePoint timePoint, Pair<HDGM, HDGM> hdgmPair) {
private Bearing getHDGM(TimePoint timePoint, com.sap.sse.common.Util.Pair<HDGM, HDGM> hdgmPair) {
final Bearing hdgm;
if (hdgmPair.getA() == null) {
if (hdgmPair.getB() == null) {
@@ -368,7 +367,7 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return hdgm;
}
private Bearing getHeading(TimePoint timePoint, Pair<HDG, HDG> hdgPair, Pair<HDGM, HDGM> hdgmPair, Position position) throws ClassNotFoundException, IOException, ParseException {
private Bearing getHeading(TimePoint timePoint, com.sap.sse.common.Util.Pair<HDG, HDG> hdgPair, com.sap.sse.common.Util.Pair<HDGM, HDGM> hdgmPair, Position position) throws ClassNotFoundException, IOException, ParseException {
final Bearing trueHeading;
Bearing hdg = getHDG(timePoint, hdgPair);
if (hdg != null) {
@@ -397,10 +396,10 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
return acc;
}
private <T extends Timed> Pair<T, T> getSurroundingFixes(Track<T> track, TimePoint timePoint) {
private <T extends Timed> com.sap.sse.common.Util.Pair<T, T> getSurroundingFixes(Track<T> track, TimePoint timePoint) {
T left = track.getLastFixAtOrBefore(timePoint);
T right = track.getFirstFixAtOrAfter(timePoint);
Pair<T, T> result = new Pair<>(left, right);
com.sap.sse.common.Util.Pair<T, T> result = new com.sap.sse.common.Util.Pair<>(left, right);
return result;
}
@@ -22,7 +22,6 @@ import org.json.simple.parser.ParseException;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.common.impl.Util;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.igtimiadapter.Account;
import com.sap.sailing.domain.igtimiadapter.BulkFixReceiver;
import com.sap.sailing.domain.igtimiadapter.LiveDataConnection;
@@ -144,8 +143,8 @@ public class WebSocketConnectionManager extends WebSocketAdapter implements Live
}
}
public Pair<TimePoint, TimePoint> getIgtimiServerTimePointAndWhenItWasReceived() {
return new Pair<TimePoint, TimePoint>(igtimiServerTimepoint, localTimepointWhenServerTimepointWasReceived);
public com.sap.sse.common.Util.Pair<TimePoint, TimePoint> getIgtimiServerTimePointAndWhenItWasReceived() {
return new com.sap.sse.common.Util.Pair<TimePoint, TimePoint>(igtimiServerTimepoint, localTimepointWhenServerTimepointWasReceived);
}
@Override