mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
started with structured SwissTiming services
This commit is contained in:
1 parent
46a81d231e
commit
1379341980
15 files changed
+130
-4
No files matched your search
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
+28
@@ -2,7 +2,35 @@ package com.sap.sailing.domain.swisstimingadapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.util.Util.Pair;
|
||||
|
||||
public interface SailMasterConnector {
|
||||
SailMasterMessage sendRequestAndGetResponse(String requestMessage) throws UnknownHostException, IOException;
|
||||
|
||||
Iterable<Race> getRaces() throws UnknownHostException, IOException;
|
||||
|
||||
Course getCourse(String raceID) throws UnknownHostException, IOException;
|
||||
|
||||
StartList getStartList(String raceID) throws UnknownHostException, IOException;
|
||||
|
||||
TimePoint getStartTime(String raceID) throws UnknownHostException, IOException;
|
||||
|
||||
/**
|
||||
* @param markIndex
|
||||
* use -1 to obtain timings for all marks
|
||||
* @return a map with the single mark requested by <code>markIndex</code> or all marks (in case of
|
||||
* <code>markIndex==-1</code>) as key; pairs of gap (TODO in milliseconds?) and boat ID as values.
|
||||
*/
|
||||
Map<Mark, Pair<Long, String>> getDeltaClockAtMark(String raceID, int markIndex) throws UnknownHostException, IOException;
|
||||
|
||||
double getDistanceToMarkInMeters(String raceID, int markIndex, String boatID) throws UnknownHostException, IOException;
|
||||
|
||||
double getCurrentBoatSpeedInMetersPerSecond(String raceID, String boatID) throws UnknownHostException, IOException;
|
||||
|
||||
double getAverageBoatSpeedInMetersPerSecond(String raceID, String leg, String boatID) throws UnknownHostException, IOException;
|
||||
|
||||
double getDistanceBetweenBoatsInMeters(String raceID, String boatID1, String boatID2) throws UnknownHostException, IOException;
|
||||
}
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
+72
@@ -4,9 +4,18 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Course;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Mark;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
import com.sap.sailing.domain.swisstimingadapter.SailMasterConnector;
|
||||
import com.sap.sailing.domain.swisstimingadapter.SailMasterMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.StartList;
|
||||
import com.sap.sailing.util.Util.Pair;
|
||||
|
||||
public class SailMasterConnectorImpl extends SailMasterTransceiver implements SailMasterConnector {
|
||||
private final String host;
|
||||
@@ -31,4 +40,67 @@ public class SailMasterConnectorImpl extends SailMasterTransceiver implements Sa
|
||||
socket = new Socket(host, port);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Race> getRaces() throws UnknownHostException, IOException {
|
||||
SailMasterMessage response = sendRequestAndGetResponse("RaceId");
|
||||
String[] sections = response.getSections();
|
||||
if (!sections[0].equals("RaceId")) {
|
||||
throw new RuntimeException("Expected a RaceId response for a RaceId request but got "+sections[0]);
|
||||
}
|
||||
List<Race> result = new ArrayList<Race>();
|
||||
for (int i=1; i<sections.length; i++) {
|
||||
String[] idAndDescription = sections[i].split(",");
|
||||
result.add(new RaceImpl(idAndDescription[1], idAndDescription[0]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course getCourse(String raceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartList getStartList(String raceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint getStartTime(String raceID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Mark, Pair<Long, String>> getDeltaClockAtMark(String raceID, int markIndex) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistanceToMarkInMeters(String raceID, int markIndex, String boatID) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentBoatSpeedInMetersPerSecond(String raceID, String boatID) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAverageBoatSpeedInMetersPerSecond(String raceID, String leg, String boatID) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistanceBetweenBoatsInMeters(String raceID, String boatID1, String boatID2) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class SailMasterMessageImpl implements SailMasterMessage {
|
||||
public String[] getSections() {
|
||||
return getMessage().split("\\|");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getMessage();
|
||||
|
||||
Regular → Executable
File mode changed.
Reference in new issue
Block a user