mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
pass correctByDeclination parameter through to Igtimi connector
This commit is contained in:
+1
-1
@@ -152,7 +152,7 @@ public interface IgtimiConnection {
|
||||
* @return the number of wind fixes imported per tracked race; contains an entry for all elements in
|
||||
* <code>trackedRaces</code>
|
||||
*/
|
||||
Map<TrackedRace, Integer> importWindIntoRace(Iterable<DynamicTrackedRace> trackedRaces) throws IllegalStateException,
|
||||
Map<TrackedRace, Integer> importWindIntoRace(Iterable<DynamicTrackedRace> trackedRaces, boolean correctByDeclination) throws IllegalStateException,
|
||||
ClientProtocolException, IOException, ParseException;
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@ import org.apache.http.client.ClientProtocolException;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.sap.sailing.declination.DeclinationService;
|
||||
import com.sap.sailing.domain.igtimiadapter.oauth.AuthorizationCallback;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ import com.sap.sailing.domain.igtimiadapter.oauth.AuthorizationCallback;
|
||||
public interface IgtimiConnectionFactory {
|
||||
Iterable<Account> getAllAccounts();
|
||||
|
||||
IgtimiConnection connect(Account account);
|
||||
IgtimiConnection connect(Account account, boolean correctByDeclination);
|
||||
|
||||
/**
|
||||
* Removes the account and the credentials associated with it permanently. The account is identified by the e-mail
|
||||
@@ -38,7 +39,7 @@ public interface IgtimiConnectionFactory {
|
||||
/**
|
||||
* Using the "account" service, retrieves the {@link Account} information for this access token and stores the token
|
||||
* that authorizes this factory's client to access the account together with the {@link Account} data. This information is
|
||||
* used when a caller wants to {@link #connect(Account)} to a specific account on behalf of the {@link Client} to
|
||||
* used when a caller wants to {@link #connect(Account, DeclinationService)} to a specific account on behalf of the {@link Client} to
|
||||
* which this factory belongs.
|
||||
* @return
|
||||
*/
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ public class IgtimiConnectionFactoryImpl implements IgtimiConnectionFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IgtimiConnection connect(Account account) {
|
||||
public IgtimiConnection connect(Account account, boolean correctByDeclination) {
|
||||
return new IgtimiConnectionImpl(this, account);
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -18,6 +18,7 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.sap.sailing.declination.DeclinationService;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.igtimiadapter.Account;
|
||||
@@ -235,8 +236,9 @@ public class IgtimiConnectionImpl implements IgtimiConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<TrackedRace, Integer> importWindIntoRace(Iterable<DynamicTrackedRace> trackedRaces) throws IllegalStateException, ClientProtocolException, IOException, ParseException {
|
||||
logger.info("Importing Igtimi wind for tracked races "+trackedRaces);
|
||||
public Map<TrackedRace, Integer> importWindIntoRace(Iterable<DynamicTrackedRace> trackedRaces,
|
||||
boolean correctByDeclination) throws IllegalStateException, ClientProtocolException, IOException, ParseException {
|
||||
logger.info("Importing Igtimi wind for tracked races " + trackedRaces);
|
||||
TimePoint startOfWindow = new MillisecondsTimePoint(Long.MAX_VALUE);
|
||||
TimePoint endOfWindow = new MillisecondsTimePoint(0);
|
||||
for (DynamicTrackedRace trackedRace : trackedRaces) {
|
||||
@@ -268,7 +270,8 @@ public class IgtimiConnectionImpl implements IgtimiConnection {
|
||||
}
|
||||
final Map<TrackedRace, Integer> result;
|
||||
if (!deviceSerialNumbers.isEmpty()) {
|
||||
IgtimiWindReceiver windReceiver = new IgtimiWindReceiver(deviceSerialNumbers);
|
||||
IgtimiWindReceiver windReceiver = new IgtimiWindReceiver(deviceSerialNumbers,
|
||||
correctByDeclination ? DeclinationService.INSTANCE : null);
|
||||
final WindListenerSendingToTrackedRace windListener = new WindListenerSendingToTrackedRace(
|
||||
trackedRaces, Activator.getInstance().getWindTrackerFactory());
|
||||
windReceiver.addListener(windListener);
|
||||
|
||||
+5
-3
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.declination.DeclinationService;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.igtimiadapter.Account;
|
||||
@@ -30,7 +31,7 @@ public class IgtimiWindTracker extends AbstractWindTracker implements WindTracke
|
||||
private boolean stopping;
|
||||
|
||||
protected IgtimiWindTracker(final DynamicTrackedRace trackedRace, final IgtimiConnectionFactory connectionFactory,
|
||||
final IgtimiWindTrackerFactory windTrackerFactory) throws Exception {
|
||||
final IgtimiWindTrackerFactory windTrackerFactory, final boolean correctByDeclination) throws Exception {
|
||||
super(trackedRace);
|
||||
this.windTrackerFactory = windTrackerFactory;
|
||||
liveConnectionsAndDeviceSerialNumber = new HashMap<>();
|
||||
@@ -43,11 +44,12 @@ public class IgtimiWindTracker extends AbstractWindTracker implements WindTracke
|
||||
for (Account account : accounts) {
|
||||
try {
|
||||
if (!stopping) {
|
||||
IgtimiConnection connection = connectionFactory.connect(account);
|
||||
IgtimiConnection connection = connectionFactory.connect(account, correctByDeclination);
|
||||
Iterable<String> devicesWeShouldListenTo = connection.getWindDevices();
|
||||
if (!stopping) {
|
||||
LiveDataConnection liveConnection = connection.getOrCreateLiveConnection(devicesWeShouldListenTo);
|
||||
IgtimiWindReceiver windReceiver = new IgtimiWindReceiver(devicesWeShouldListenTo);
|
||||
IgtimiWindReceiver windReceiver = new IgtimiWindReceiver(devicesWeShouldListenTo,
|
||||
correctByDeclination ? DeclinationService.INSTANCE : null);
|
||||
liveConnection.addListener(windReceiver);
|
||||
windReceiver.addListener(new WindListenerSendingToTrackedRace(Collections.singleton(getTrackedRace()), windTrackerFactory));
|
||||
liveConnectionsAndDeviceSerialNumber.put(liveConnection, new Util.Pair<Iterable<String>, Account>(devicesWeShouldListenTo, account));
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class IgtimiWindTrackerFactory implements WindTrackerFactory {
|
||||
public WindTracker createWindTracker(DynamicTrackedRegatta trackedRegatta, RaceDefinition race,
|
||||
boolean correctByDeclination) throws Exception {
|
||||
DynamicTrackedRace trackedRace = trackedRegatta.getTrackedRace(race);
|
||||
IgtimiWindTracker windTracker = new IgtimiWindTracker(trackedRace, connectionFactory, this);
|
||||
IgtimiWindTracker windTracker = new IgtimiWindTracker(trackedRace, connectionFactory, this, correctByDeclination);
|
||||
trackersForRace.put(race, windTracker);
|
||||
return windTracker;
|
||||
}
|
||||
|
||||
+8
-4
@@ -109,9 +109,9 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
public IgtimiWindReceiver(Iterable<String> deviceSerialNumbers) {
|
||||
public IgtimiWindReceiver(Iterable<String> deviceSerialNumbers, DeclinationService declinationService) {
|
||||
receiver = new FixReceiver();
|
||||
declinationService = DeclinationService.INSTANCE;
|
||||
this.declinationService = declinationService;
|
||||
listeners = new ConcurrentHashMap<>();
|
||||
awaTrack = new HashMap<>();
|
||||
awsTrack = new HashMap<>();
|
||||
@@ -375,8 +375,12 @@ public class IgtimiWindReceiver implements BulkFixReceiver {
|
||||
} else {
|
||||
Bearing hdgm = getHDGM(timePoint, hdgmPair);
|
||||
if (hdgm != null) {
|
||||
Declination declination = declinationService.getDeclination(timePoint, position, /* timeoutForOnlineFetchInMilliseconds 5s */ 5000);
|
||||
trueHeading = hdgm.add(declination.getBearingCorrectedTo(timePoint));
|
||||
if (declinationService == null) {
|
||||
trueHeading = hdgm;
|
||||
} else {
|
||||
Declination declination = declinationService.getDeclination(timePoint, position, /* timeoutForOnlineFetchInMilliseconds 5s */ 5000);
|
||||
trueHeading = hdgm.add(declination.getBearingCorrectedTo(timePoint));
|
||||
}
|
||||
} else {
|
||||
trueHeading = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user