mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 02:43:53 +00:00
Merge branch 'gwt' of ssh://kielweek.web4sap.com:22/home/trac/git into messagescripttest
This commit is contained in:
commit
326c89940a
14 files changed
+5322
-23
No files matched your search
Executable
+1
@@ -0,0 +1 @@
|
||||
RPD|W4702|1|2011-06-06T17:53:33+02:00|||||61|SB;2;0;50.621924;-2.366136;0.2;;;265;;;;|MB4;4;0;50.604930;-2.373313;0.6;;;54;;;;|MB3;4;0;50.607337;-2.388468;1.0;;;136;;;;|MB2;4;0;50.617519;-2.352385;0.4;;;90;;;;|MB1;4;0;50.619671;-2.363580;1.2;;;355;;;;|M7;5;0;50.621848;-2.366225;0.0;;;90;;;;|M6;5;0;50.607566;-2.387956;0.2;;;273;;;;|M5;5;0;50.605087;-2.373595;0.6;;;66;;;;|M4;5;0;50.617068;-2.352154;0.6;;;212;;;;|M3;5;0;50.620260;-2.367011;0.6;;;12;;;;|M2;5;0;50.619847;-2.366434;0.4;;;230;;;;|M1;5;0;50.617344;-2.352823;0.4;;;50;;;;|FP;4;0;50.617512;-2.352427;0.2;;;359;;;;|FB;4;0;50.619166;-2.354389;0.6;;;276;;;;|SP;4;0;50.619837;-2.363837;0.2;;;270;;;;|ARG 8;1;0;50.621622;-2.364855;1.7;;;194;0;;;|AUS 7;1;0;50.621366;-2.364785;0.8;;;225;0;;;|AUT 431;1;0;50.621969;-2.365582;4.1;;;284;0;;;|BRA 177;1;0;50.622180;-2.366119;2.5;;;164;0;;;|BRA 1187;1;0;50.622095;-2.365624;1.4;;;342;0;;;|CAN 11;1;0;50.621393;-2.364657;3.3;;;180;0;;;|CAN 610;1;0;50.622365;-2.366316;5.2;;;95;0;;;|CHN 1211;1;0;50.621829;-2.365448;1.0;;;180;0;;;|CHN 1261;1;0;50.621658;-2.365081;3.9;;;98;0;;;|CHN 221;1;0;50.620723;-2.363719;3.1;;;164;0;;;|CHN 616;1;0;50.621078;-2.363683;6.8;;;148;0;;;|CRO 111;1;0;50.621267;-2.364771;0.8;;;207;0;;;|DEN 143;1;0;50.621164;-2.364446;1.0;;;180;0;;;|ESP 133;1;;;;;;;;;;;|ESP 696;1;0;50.621407;-2.364891;0.6;;;342;0;;;|EST 20;1;0;50.621339;-2.364961;3.7;;;304;0;;;|FRA 12;1;0;50.620660;-2.364348;8.2;;;320;0;;;|FRA 4;1;0;50.621501;-2.364664;6.8;;;312;0;;;|FRA 9;1;0;50.621015;-2.364185;4.7;;;148;0;;;|GBR 812;1;0;50.622031;-2.365892;2.1;;;135;0;;;|GBR 831;1;;;;;;;;;;;|GBR 841;1;0;50.621179;-2.364545;1.6;;;149;0;;;|GBR 847;1;0;50.621997;-2.365451;5.1;;;307;0;;;|GBR 850;1;0;50.621592;-2.365027;3.9;;;157;0;;;|GBR 855;1;0;50.620441;-2.363510;4.1;;;186;0;;;|GER 12;1;0;50.621716;-2.365154;1.9;;;212;0;;;|GER 21;1;0;50.621028;-2.364316;1.0;;;163;0;;;|GER 61;1;0;50.620949;-2.364182;0.8;;;225;0;;;|GER 66;1;0;50.620372;-2.363621;4.9;;;118;0;;;|GER 72;1;0;50.621779;-2.365346;2.3;;;169;0;;;|ISR 311;1;0;50.622142;-2.365735;5.6;;;14;0;;;|ITA 23;1;0;50.621072;-2.364239;3.3;;;135;0;;;|JPN 4151;1;0;50.620611;-2.363847;4.7;;;99;0;;;|JPN 4321;1;0;50.621223;-2.364568;2.7;;;232;0;;;|NED 11;1;0;50.620450;-2.363814;5.6;;;6;0;;;|NED 24;1;;;;;;;;;;;|NZL 75;1;0;50.621525;-2.364947;3.9;;;308;0;;;|RUS 12;1;0;50.622490;-2.366622;1.2;;;189;0;;;|RUS 700;1;0;50.622272;-2.366104;3.9;;;85;0;;;|SLO 64;1;0;50.621284;-2.364426;4.9;;;129;0;;;|SUI 14;1;0;50.621851;-2.365533;1.2;;;183;0;;;|SWE 342;1;0;50.620863;-2.364372;1.9;;;170;0;;;|SWE 344;1;0;50.620573;-2.363707;5.6;;;325;0;;;|USA 1712;1;0;50.621914;-2.365508;1.2;;;200;0;;;|USA 1736;1;0;50.620716;-2.364131;6.6;;;134;0;;;|USA 1757;1;0;50.620797;-2.364135;5.4;;;146;0;;;RPD|W4702|1|2011-06-06T17:53:34+02:00|||||61|SB;2;0;50.621924;-2.366140;0.2;;;270;;;;|MB4;4;0;50.604929;-2.373314;0.6;;;90;;;;|MB3;4;0;50.607332;-2.388461;1.0;;;135;;;;|MB2;4;0;50.617519;-2.352385;0.4;;;90;;;;|MB1;4;0;50.619680;-2.363579;1.2;;;0;;;;|M7;5;0;50.621848;-2.366225;0.0;;;90;;;;|M6;5;0;50.607566;-2.387953;0.2;;;90;;;;|M5;5;0;50.605082;-2.373596;0.6;;;180;;;;|M4;5;0;50.617069;-2.352152;0.6;;;90;;;;|M3;5;0;50.620262;-2.367012;0.6;;;0;;;;|M2;5;0;50.619848;-2.366433;0.4;;;90;;;;|M1;5;0;50.617344;-2.352823;0.4;;;90;;;;|FP;4;0;50.617515;-2.352427;0.2;;;0;;;;|FB;4;0;50.619166;-2.354388;0.6;;;90;;;;|SP;4;0;50.619837;-2.363840;0.2;;;270;;;;|ARG 8;1;0;50.621613;-2.364855;2.1;;;180;0;;;|AUS 7;1;0;50.621363;-2.364787;1.0;;;208;0;;;|AUT 431;1;0;50.621973;-2.365611;4.1;;;282;0;;;|BRA 177;1;0;50.622172;-2.366088;3.9;;;113;0;;;|BRA 1187;1;0;50.622098;-2.365630;1.0;;;309;0;;;|CAN 11;1;0;50.621378;-2.364661;3.3;;;188;0;;;|CAN 610;1;0;50.622368;-2.366278;5.1;;;83;0;;;|CHN 1211;1;0;50.621827;-2.365451;0.8;;;223;0;;;|CHN 1261;1;0;50.621648;-2.365079;3.1;;;175;0;;;|CHN 221;1;0;50.620704;-2.363715;3.5;;;173;0;;;|CHN 616;1;0;50.621052;-2.363657;6.8;;;147;0;;;|CRO 111;1;0;50.621263;-2.364774;0.6;;;207;0;;;|DEN 143;1;0;50.621159;-2.364444;1.6;;;164;0;;;|ESP 133;1;0;50.620851;-2.364031;2.1;;;154;0;;;|ESP 696;1;0;50.621410;-2.364894;1.2;;;331;0;;;|EST 20;1;0;50.621361;-2.364987;5.6;;;324;0;;;|FRA 12;1;0;50.620688;-2.364385;8.2;;;319;0;;;|FRA 4;1;0;50.621521;-2.364695;6.2;;;316;0;;;|FRA 9;1;0;50.620998;-2.364175;3.7;;;160;0;;;|GBR 812;1;0;50.622014;-2.365872;2.1;;;139;0;;;|GBR 831;1;;;;;;;;;;;|GBR 841;1;0;50.621173;-2.364538;1.6;;;146;0;;;|GBR 847;1;0;50.622023;-2.365476;5.1;;;318;0;;;|GBR 850;1;0;50.621577;-2.365017;3.9;;;157;0;;;|GBR 855;1;0;50.620426;-2.363514;4.1;;;188;0;;;|GER 12;1;0;50.621708;-2.365166;1.9;;;217;0;;;|GER 21;1;0;50.621024;-2.364319;1.0;;;180;0;;;|GER 61;1;0;50.620948;-2.364185;0.8;;;225;0;;;|GER 66;1;0;50.620354;-2.363599;4.9;;;131;0;;;|GER 72;1;0;50.621771;-2.365349;2.3;;;180;0;;;|ISR 311;1;0;50.622162;-2.365723;5.6;;;17;0;;;|ITA 23;1;0;50.621060;-2.364234;3.3;;;149;0;;;|JPN 4151;1;0;50.620601;-2.363818;4.7;;;108;0;;;|JPN 4321;1;0;50.621222;-2.364587;2.7;;;248;0;;;|NED 11;1;0;50.620480;-2.363825;5.6;;;356;0;;;|NED 24;1;;;;;;;;;;;|NZLLine truncated
|
||||
+4954
File diff suppressed because it is too large.
Load diff
+47
@@ -0,0 +1,47 @@
|
||||
RAC|1|W4702;A simulated SwissTiming race
|
||||
STL|W4702|1|GER 12;GER;Competitor 25
|
||||
STL|W4702|1|GBR 812;GBR;Competitor 19
|
||||
STL|W4702|1|NED 24;NED;Competitor 35
|
||||
STL|W4702|1|CRO 111;CRO;Competitor 11
|
||||
STL|W4702|1|ARG 8;ARG;Competitor 0
|
||||
STL|W4702|1|FRA 12;FRA;Competitor 16
|
||||
STL|W4702|1|CAN 610;CAN;Competitor 6
|
||||
STL|W4702|1|CHN 616;CHN;Competitor 10
|
||||
STL|W4702|1|CHN 1261;CHN;Competitor 8
|
||||
STL|W4702|1|ESP 133;ESP;Competitor 13
|
||||
STL|W4702|1|GER 72;GER;Competitor 29
|
||||
STL|W4702|1|EST 20;EST;Competitor 15
|
||||
STL|W4702|1|NZL 75;NZL;Competitor 36
|
||||
STL|W4702|1|SLO 64;SLO;Competitor 39
|
||||
STL|W4702|1|GBR 831;GBR;Competitor 20
|
||||
STL|W4702|1|RUS 12;RUS;Competitor 37
|
||||
STL|W4702|1|ITA 23;ITA;Competitor 31
|
||||
STL|W4702|1|ESP 696;ESP;Competitor 14
|
||||
STL|W4702|1|GBR 847;GBR;Competitor 22
|
||||
STL|W4702|1|DEN 143;DEN;Competitor 12
|
||||
STL|W4702|1|ISR 311;ISR;Competitor 30
|
||||
STL|W4702|1|GER 21;GER;Competitor 26
|
||||
STL|W4702|1|NED 11;NED;Competitor 34
|
||||
STL|W4702|1|GBR 850;GBR;Competitor 23
|
||||
STL|W4702|1|BRA 177;BRA;Competitor 3
|
||||
STL|W4702|1|AUT 431;AUT;Competitor 2
|
||||
STL|W4702|1|FRA 9;FRA;Competitor 18
|
||||
STL|W4702|1|FRA 4;FRA;Competitor 17
|
||||
STL|W4702|1|GBR 855;GBR;Competitor 24
|
||||
STL|W4702|1|BRA 1187;BRA;Competitor 4
|
||||
STL|W4702|1|USA 1712;USA;Competitor 43
|
||||
STL|W4702|1|SWE 344;SWE;Competitor 42
|
||||
STL|W4702|1|GER 61;GER;Competitor 27
|
||||
STL|W4702|1|SWE 342;SWE;Competitor 41
|
||||
STL|W4702|1|CHN 1211;CHN;Competitor 7
|
||||
STL|W4702|1|USA 1757;USA;Competitor 45
|
||||
STL|W4702|1|GER 66;GER;Competitor 28
|
||||
STL|W4702|1|SUI 14;SUI;Competitor 40
|
||||
STL|W4702|1|JPN 4151;JPN;Competitor 32
|
||||
STL|W4702|1|JPN 4321;JPN;Competitor 33
|
||||
STL|W4702|1|CAN 11;CAN;Competitor 5
|
||||
STL|W4702|1|AUS 7;AUS;Competitor 1
|
||||
STL|W4702|1|USA 1736;USA;Competitor 44
|
||||
STL|W4702|1|RUS 700;RUS;Competitor 38
|
||||
STL|W4702|1|CHN 221;CHN;Competitor 9
|
||||
STL|W4702|1|GBR 841;GBR;Competitor 21
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScriptedMessagesReader {
|
||||
|
||||
protected List<String> messages;
|
||||
|
||||
public ScriptedMessagesReader() {
|
||||
messages = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public int getMessageCount() {
|
||||
return messages.size();
|
||||
}
|
||||
|
||||
public boolean addMessagesFromRawMessageFile(InputStream scriptInputStream) {
|
||||
Map<String, Integer> messageTypes = new HashMap<String, Integer>();
|
||||
try {
|
||||
// read the script from an inputstream
|
||||
DataInputStream in = new DataInputStream(scriptInputStream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
char STX = '\u0002'; // ascii for START OF TEXT
|
||||
char ETX = '\u0003'; // ascii for END OF TEXT
|
||||
|
||||
StreamTokenizer tokenizer = new StreamTokenizer(br);
|
||||
tokenizer.ordinaryChar(STX);
|
||||
tokenizer.ordinaryChar(ETX);
|
||||
|
||||
char[] validChars = new char[] { '|', ':', ';', '+', '-', ' '};
|
||||
for(char c: validChars)
|
||||
tokenizer.wordChars(c, c);
|
||||
|
||||
int token;
|
||||
while((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) {
|
||||
|
||||
switch(token) {
|
||||
case StreamTokenizer.TT_WORD:
|
||||
String s = tokenizer.sval;
|
||||
|
||||
String type = s.substring(0, 3);
|
||||
|
||||
if(messageTypes.containsKey(type) == false) {
|
||||
messageTypes.put(type, 1);
|
||||
} else {
|
||||
messageTypes.put(type, messageTypes.get(type) + 1);
|
||||
}
|
||||
/*
|
||||
if("TMD".equals(type)) // just for internal analysis
|
||||
{
|
||||
System.out.println(type + " message with length " + s.length());
|
||||
System.out.println(s);
|
||||
|
||||
String[] xyz = s.split("\\|");
|
||||
String race = xyz[1];
|
||||
String boat = xyz[2];
|
||||
|
||||
if(comp.containsKey(boat) == false)
|
||||
comp.put(boat, "STL|"+ race + "|1|" + boat + ";" + boat.substring(0,3) + ";Competitor " + comp.size());
|
||||
}
|
||||
*/
|
||||
messages.add(s);
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
System.out.println(messages.size());
|
||||
System.out.println(messageTypes);
|
||||
|
||||
System.out.println(comp.size());
|
||||
for(String stl: comp.values())
|
||||
System.out.println(stl);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addMessagesFromTextFile(InputStream scriptInputStream) {
|
||||
|
||||
try {
|
||||
// read the script from an inputstream
|
||||
DataInputStream in = new DataInputStream(scriptInputStream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
String strLine;
|
||||
|
||||
// read line by line
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
messages.add(strLine);
|
||||
}
|
||||
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addMessagesFromListScriptedMessagesReader(List<String> scriptMessages) {
|
||||
this.messages.addAll(scriptMessages);
|
||||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(List<String> scriptMessages) {
|
||||
this.messages = scriptMessages;
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -15,7 +15,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
|
||||
@@ -6,7 +6,8 @@ Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.sap.sailing.domain,
|
||||
com.sap.sailing.udpconnector
|
||||
com.sap.sailing.udpconnector,
|
||||
com.googlecode.java-diff-utils;bundle-version="1.3.0"
|
||||
Import-Package: org.osgi.framework
|
||||
Export-Package: com.sap.sailing.domain.swisstimingadapter,
|
||||
com.sap.sailing.domain.swisstimingadapter.impl;x-friends:="com.sap.sailing.domain.swisstimingadapter.test"
|
||||
+11
-2
@@ -2,12 +2,17 @@ package com.sap.sailing.domain.swisstimingadapter;
|
||||
|
||||
import com.sap.sailing.domain.base.Buoy;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.swisstimingadapter.impl.DomainFactoryImpl;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
|
||||
import difflib.PatchFailedException;
|
||||
|
||||
public interface DomainFactory {
|
||||
final static DomainFactory INSTANCE = new DomainFactoryImpl();
|
||||
@@ -18,11 +23,15 @@ public interface DomainFactory {
|
||||
|
||||
Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor);
|
||||
|
||||
RaceDefinition createRaceDefinition(Event event, Race race, StartList startList, Course course);
|
||||
RaceDefinition createRaceDefinition(Event event, Race race, StartList startList, com.sap.sailing.domain.swisstimingadapter.Course course);
|
||||
|
||||
Buoy getOrCreateBuoy(String trackerID);
|
||||
|
||||
GPSFixMoving createGPSFix(TimePoint timePointOfTransmission, Fix fix);
|
||||
|
||||
Competitor getCompetitorByBoatID(String sailNumber);
|
||||
Competitor getCompetitorByBoatID(String boatID);
|
||||
|
||||
void updateCourseWaypoints(Course courseToUpdate, Iterable<Mark> marks) throws PatchFailedException;
|
||||
|
||||
MarkPassing createMarkPassing(String raceID, String boatID, Waypoint waypoint, TimePoint timePoint);
|
||||
}
|
||||
+51
@@ -3,6 +3,7 @@ package com.sap.sailing.domain.swisstimingadapter.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -36,9 +37,16 @@ import com.sap.sailing.domain.swisstimingadapter.MessageType;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
import com.sap.sailing.domain.swisstimingadapter.StartList;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
import com.sap.sailing.domain.tracking.impl.GPSFixMovingImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.MarkPassingImpl;
|
||||
import com.sap.sailing.util.CourseAsWaypointList;
|
||||
import com.sap.sailing.util.Util;
|
||||
|
||||
import difflib.DiffUtils;
|
||||
import difflib.Patch;
|
||||
import difflib.PatchFailedException;
|
||||
|
||||
public class DomainFactoryImpl implements DomainFactory {
|
||||
private final Map<String, Event> raceIDToEventCache;
|
||||
private final Map<String, Competitor> boatIDToCompetitorCache;
|
||||
@@ -168,4 +176,47 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
timePointOfTransmission.asMillis() + fix.getAgeOfDataInMilliseconds()), fix.getSpeed());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCourseWaypoints(com.sap.sailing.domain.base.Course courseToUpdate, Iterable<Mark> marks) throws PatchFailedException {
|
||||
Iterable<Waypoint> courseWaypoints = courseToUpdate.getWaypoints();
|
||||
List<Waypoint> newWaypointList = new LinkedList<Waypoint>();
|
||||
// key existing waypoints by control points and re-use each one at most once during construction of the
|
||||
// new waypoint list; since several waypoints can have the same control point, the map goes from
|
||||
// control point to List<Waypoint>. The waypoints in the lists are held in the order of their
|
||||
// occurrence in courseToUpdate.getWaypoints().
|
||||
Map<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>> existingWaypointsByControlPoint =
|
||||
new HashMap<com.sap.sailing.domain.base.ControlPoint, List<Waypoint>>();
|
||||
for (Waypoint waypoint : courseToUpdate.getWaypoints()) {
|
||||
List<Waypoint> wpl = existingWaypointsByControlPoint.get(waypoint.getControlPoint());
|
||||
if (wpl == null) {
|
||||
wpl = new ArrayList<Waypoint>();
|
||||
existingWaypointsByControlPoint.put(waypoint.getControlPoint(), wpl);
|
||||
}
|
||||
wpl.add(waypoint);
|
||||
}
|
||||
for (Mark mark : marks) {
|
||||
com.sap.sailing.domain.base.ControlPoint domainControlPoint = getOrCreateControlPoint(mark.getDevices());
|
||||
List<Waypoint> waypoints = existingWaypointsByControlPoint.get(domainControlPoint);
|
||||
Waypoint waypoint;
|
||||
if (waypoints == null || waypoints.isEmpty()) {
|
||||
// must be a new control point for which we don't have a waypoint yet
|
||||
waypoint = new WaypointImpl(domainControlPoint);
|
||||
} else {
|
||||
waypoint = waypoints.remove(0); // take the first from the list
|
||||
}
|
||||
newWaypointList.add(waypoint);
|
||||
}
|
||||
Patch<Waypoint> patch = DiffUtils.diff(courseWaypoints, newWaypointList);
|
||||
CourseAsWaypointList courseAsWaypointList = new CourseAsWaypointList(courseToUpdate);
|
||||
synchronized (courseToUpdate) {
|
||||
patch.applyToInPlace(courseAsWaypointList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkPassing createMarkPassing(String raceID, String boatID, Waypoint waypoint, TimePoint timePoint) {
|
||||
return new MarkPassingImpl(timePoint, waypoint, getCompetitorByBoatID(boatID));
|
||||
}
|
||||
|
||||
}
|
||||
+73
-12
@@ -327,19 +327,45 @@ public class SailMasterConnectorImpl extends SailMasterTransceiverImpl implement
|
||||
markIndicesRanksAndTimesSinceStartInMilliseconds.add(new Triple<Integer, Integer, Long>(markIndex, rank, timeSinceStartInMilliseconds));
|
||||
}
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedTimingData(raceID, boatID, markIndicesRanksAndTimesSinceStartInMilliseconds);
|
||||
try {
|
||||
listener.receivedTimingData(raceID, boatID, markIndicesRanksAndTimesSinceStartInMilliseconds);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersTMD", t);
|
||||
}
|
||||
}
|
||||
Set<SailMasterListener> raceSpecificListenerSet = raceSpecificListeners.get(message.getRaceID());
|
||||
if (raceSpecificListenerSet != null) {
|
||||
for (SailMasterListener listener : raceSpecificListenerSet) {
|
||||
try {
|
||||
listener.receivedTimingData(raceID, boatID, markIndicesRanksAndTimesSinceStartInMilliseconds);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersTMD", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyListenersCAM(SailMasterMessage message) throws ParseException {
|
||||
List<Triple<Integer, TimePoint, String>> clockAtMarkResults = parseClockAtMarkMessage(message);
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedClockAtMark(message.getSections()[1], clockAtMarkResults);
|
||||
try {
|
||||
listener.receivedClockAtMark(message.getSections()[1], clockAtMarkResults);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersCAM", t);
|
||||
}
|
||||
}
|
||||
Set<SailMasterListener> raceSpecificListenerSet = raceSpecificListeners.get(message.getRaceID());
|
||||
if (raceSpecificListenerSet != null) {
|
||||
for (SailMasterListener listener : raceSpecificListenerSet) {
|
||||
listener.receivedClockAtMark(message.getSections()[1], clockAtMarkResults);
|
||||
try {
|
||||
listener.receivedClockAtMark(message.getSections()[1], clockAtMarkResults);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersCAM", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,12 +373,22 @@ public class SailMasterConnectorImpl extends SailMasterTransceiverImpl implement
|
||||
private void notifyListenersSTL(SailMasterMessage message) {
|
||||
StartList startListMessage = parseStartListMessage(message);
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedStartList(message.getSections()[1], startListMessage);
|
||||
try {
|
||||
listener.receivedStartList(message.getSections()[1], startListMessage);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersSTL", t);
|
||||
}
|
||||
}
|
||||
Set<SailMasterListener> raceSpecificListenerSet = raceSpecificListeners.get(message.getRaceID());
|
||||
if (raceSpecificListenerSet != null) {
|
||||
for (SailMasterListener listener : raceSpecificListenerSet) {
|
||||
listener.receivedStartList(message.getSections()[1], startListMessage);
|
||||
try {
|
||||
listener.receivedStartList(message.getSections()[1], startListMessage);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersSTL", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,12 +396,22 @@ public class SailMasterConnectorImpl extends SailMasterTransceiverImpl implement
|
||||
private void notifyListenersCCG(SailMasterMessage message) {
|
||||
Course course = parseCourseConfigurationMessage(message);
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedCourseConfiguration(message.getSections()[1], course);
|
||||
try {
|
||||
listener.receivedCourseConfiguration(message.getSections()[1], course);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersCCG", t);
|
||||
}
|
||||
}
|
||||
Set<SailMasterListener> raceSpecificListenerSet = raceSpecificListeners.get(message.getRaceID());
|
||||
if (raceSpecificListenerSet != null) {
|
||||
for (SailMasterListener listener : raceSpecificListenerSet) {
|
||||
listener.receivedCourseConfiguration(message.getSections()[1], course);
|
||||
try {
|
||||
listener.receivedCourseConfiguration(message.getSections()[1], course);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersCCG", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +419,12 @@ public class SailMasterConnectorImpl extends SailMasterTransceiverImpl implement
|
||||
private void notifyListenersRAC(SailMasterMessage message) {
|
||||
Iterable<Race> races = parseAvailableRacesMessage(message);
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedAvailableRaces(races);
|
||||
try {
|
||||
listener.receivedAvailableRaces(races);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersRAC", t);
|
||||
}
|
||||
}
|
||||
// not race specific; no need to notify any listener from raceSpecificListeners
|
||||
}
|
||||
@@ -430,14 +481,24 @@ public class SailMasterConnectorImpl extends SailMasterTransceiverImpl implement
|
||||
}
|
||||
}
|
||||
for (SailMasterListener listener : listeners) {
|
||||
listener.receivedRacePositionData(raceID, status, timePoint, startTimeEstimatedStartTime, millisecondsSinceRaceStart,
|
||||
nextMarkIndexForLeader, distanceToNextMarkForLeader, fixes);
|
||||
try {
|
||||
listener.receivedRacePositionData(raceID, status, timePoint, startTimeEstimatedStartTime, millisecondsSinceRaceStart,
|
||||
nextMarkIndexForLeader, distanceToNextMarkForLeader, fixes);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersRPD", t);
|
||||
}
|
||||
}
|
||||
Set<SailMasterListener> raceSpecificListenerSet = raceSpecificListeners.get(message.getRaceID());
|
||||
if (raceSpecificListenerSet != null) {
|
||||
for (SailMasterListener listener : raceSpecificListenerSet) {
|
||||
listener.receivedRacePositionData(raceID, status, timePoint, startTimeEstimatedStartTime, millisecondsSinceRaceStart,
|
||||
nextMarkIndexForLeader, distanceToNextMarkForLeader, fixes);
|
||||
try {
|
||||
listener.receivedRacePositionData(raceID, status, timePoint, startTimeEstimatedStartTime, millisecondsSinceRaceStart,
|
||||
nextMarkIndexForLeader, distanceToNextMarkForLeader, fixes);
|
||||
} catch (Throwable t) {
|
||||
logger.info("Exception occurred trying to notify listener "+listener+" about "+message+": "+t.getMessage());
|
||||
logger.throwing(SailMasterConnectorImpl.class.getName(), "notifyListenersRPD", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-5
@@ -8,6 +8,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.Buoy;
|
||||
@@ -16,6 +17,8 @@ import com.sap.sailing.domain.base.Distance;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Course;
|
||||
import com.sap.sailing.domain.swisstimingadapter.DomainFactory;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Fix;
|
||||
@@ -34,13 +37,17 @@ import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.GPSFix;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
import com.sap.sailing.domain.tracking.RaceHandle;
|
||||
import com.sap.sailing.domain.tracking.RaceTracker;
|
||||
import com.sap.sailing.domain.tracking.TrackedEventRegistry;
|
||||
import com.sap.sailing.domain.tracking.WindStore;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
import com.sap.sailing.util.Util;
|
||||
import com.sap.sailing.util.Util.Triple;
|
||||
|
||||
import difflib.PatchFailedException;
|
||||
|
||||
public class SwissTimingRaceTrackerImpl implements SwissTimingRaceTracker, SailMasterListener {
|
||||
private static final Logger logger = Logger.getLogger(SwissTimingRaceTrackerImpl.class.getName());
|
||||
|
||||
@@ -161,23 +168,41 @@ public class SwissTimingRaceTrackerImpl implements SwissTimingRaceTracker, SailM
|
||||
competitorTrack.addGPSFix(gpsFix);
|
||||
break;
|
||||
default:
|
||||
logger.info("Unknoen tracker type "+fix.getTrackerType());
|
||||
logger.info("Unknown tracker type "+fix.getTrackerType());
|
||||
}
|
||||
}
|
||||
// TODO implement receivedRacePositionData; extract race start time, add GPSFixMoving objects to tracked race
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedTimingData(String raceID, String boatID,
|
||||
List<Triple<Integer, Integer, Long>> markIndicesRanksAndTimesSinceStartInMilliseconds) {
|
||||
// TODO implement receivedTimingData; generate MarkPassing objects and update tracked race accordingly
|
||||
assert this.raceID.equals(raceID);
|
||||
Competitor competitor = domainFactory.getCompetitorByBoatID(boatID);
|
||||
// the list of mark indices and time stamps is partial and usually only shows the last mark passing;
|
||||
// we need to use this to *update* the competitor's mark passings list, not *replace* it
|
||||
TreeMap<Integer, MarkPassing> markPassingsByMarkIndex = new TreeMap<Integer, MarkPassing>();
|
||||
// now fill with the already existing mark passings for the competitor identified by boatID...
|
||||
for (MarkPassing markPassing : trackedRace.getMarkPassings(competitor)) {
|
||||
markPassingsByMarkIndex.put(trackedRace.getRace().getCourse().getIndexOfWaypoint(markPassing.getWaypoint()), markPassing);
|
||||
}
|
||||
// ...and then overwrite those for which we received "new evidence"
|
||||
for (Triple<Integer, Integer, Long> markIndexRankAndTimeSinceStartInMilliseconds : markIndicesRanksAndTimesSinceStartInMilliseconds) {
|
||||
Waypoint waypoint = Util.get(trackedRace.getRace().getCourse().getWaypoints(),
|
||||
markIndexRankAndTimeSinceStartInMilliseconds.getA());
|
||||
MillisecondsTimePoint timePoint = new MillisecondsTimePoint(trackedRace.getStart().asMillis()
|
||||
+ markIndexRankAndTimeSinceStartInMilliseconds.getC());
|
||||
MarkPassing markPassing = domainFactory.createMarkPassing(raceID, boatID, waypoint, timePoint);
|
||||
markPassingsByMarkIndex.put(markIndexRankAndTimeSinceStartInMilliseconds.getA(), markPassing);
|
||||
}
|
||||
trackedRace.updateMarkPassings(competitor, markPassingsByMarkIndex.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedClockAtMark(String raceID,
|
||||
List<Triple<Integer, TimePoint, String>> markIndicesTimePointsAndBoatIDs) {
|
||||
// TODO implement receivedClockAtMark; generateMarkPassing object and update tracked race accordingly
|
||||
// Ignored because it's covered by TMD. Mail from Kai Hahndorf of 2011-11-15T12:42:00Z:
|
||||
// "Die TMD werden immer gesendet. Das CAM Protokoll ist nur für unsere TV-Grafik wichtig, da damit die Rückstandsuhr gestartet wird."
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,7 +239,12 @@ public class SwissTimingRaceTrackerImpl implements SwissTimingRaceTracker, SailM
|
||||
createRaceDefinition(raceID);
|
||||
}
|
||||
} else {
|
||||
// TODO update trackedRace with updated course
|
||||
try {
|
||||
domainFactory.updateCourseWaypoints(trackedRace.getRace().getCourse(), course.getMarks());
|
||||
} catch (PatchFailedException e) {
|
||||
logger.info("Internal error trying to update course: "+e.getMessage());
|
||||
logger.throwing(SwissTimingRaceTrackerImpl.class.getName(), "receivedCourseConfiguration", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -62,6 +62,7 @@ import com.sap.sailing.domain.tractracadapter.Receiver;
|
||||
import com.sap.sailing.domain.tractracadapter.ReceiverType;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracConfiguration;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracRaceTracker;
|
||||
import com.sap.sailing.util.CourseAsWaypointList;
|
||||
import com.sap.sailing.util.Util;
|
||||
import com.sap.sailing.util.Util.Pair;
|
||||
import com.tractrac.clientmodule.CompetitorClass;
|
||||
|
||||
@@ -15,3 +15,4 @@ Export-Package: com.sap.sailing.domain.base,
|
||||
com.sap.sailing.domain.tracking.impl,
|
||||
com.sap.sailing.util
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: com.googlecode.java-diff-utils;bundle-version="1.3.0"
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
package com.sap.sailing.domain.tractracadapter.impl;
|
||||
package com.sap.sailing.util;
|
||||
|
||||
import java.util.AbstractList;
|
||||
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.util.Util;
|
||||
|
||||
import difflib.Patch;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sap.sailing.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class Util {
|
||||
public static <T> int size(Iterable<T> i) {
|
||||
@@ -17,6 +18,20 @@ public class Util {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T get(Iterable<T> iterable, int i) {
|
||||
if (iterable instanceof List<?>) {
|
||||
List<T> l = (List<T>) iterable;
|
||||
return l.get(i);
|
||||
} else {
|
||||
Iterator<T> iter = iterable.iterator();
|
||||
T result = iter.next();
|
||||
for (int j=0; j<i; j++) {
|
||||
result = iter.next();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> boolean contains(Iterable<T> ts, T t) {
|
||||
if (ts instanceof Collection<?>) {
|
||||
|
||||
Reference in new issue
Block a user