mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
cleanup of simulator implementation;
This commit is contained in:
1 parent
c2ea7e3965
commit
189b3be8ff
9 files changed
+253
-474
No files matched your search
+9
-9
@@ -64,7 +64,7 @@ import com.sap.sailing.simulator.Grid;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PathType;
|
||||
import com.sap.sailing.simulator.PolarDiagram;
|
||||
import com.sap.sailing.simulator.SailingSimulator;
|
||||
import com.sap.sailing.simulator.Simulator;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.TimedPosition;
|
||||
import com.sap.sailing.simulator.TimedPositionWithSpeed;
|
||||
@@ -74,7 +74,7 @@ import com.sap.sailing.simulator.impl.PathGenerator1Turner;
|
||||
import com.sap.sailing.simulator.impl.PathImpl;
|
||||
import com.sap.sailing.simulator.impl.PolarDiagramCSV;
|
||||
import com.sap.sailing.simulator.impl.ReadingConfigurationFileStatus;
|
||||
import com.sap.sailing.simulator.impl.SailingSimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulationParametersImpl;
|
||||
import com.sap.sailing.simulator.impl.TimedPositionImpl;
|
||||
import com.sap.sailing.simulator.impl.TimedPositionWithSpeedImpl;
|
||||
@@ -406,7 +406,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
PolarDiagram polarDiagram = polarDiagramAndNotificationMessage.getA();
|
||||
String notificationMessage = polarDiagramAndNotificationMessage.getB();
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(new SimulationParametersImpl(null, polarDiagram, null,
|
||||
Simulator simulator = new SimulatorImpl(new SimulationParametersImpl(null, polarDiagram, null,
|
||||
null, SailingSimulatorConstants.ModeMeasured, true, true));
|
||||
Path gpsTrack = simulator.getLegGPSTrack(SimulatorServiceUtils.toSimulatorUISelection(requestData.selection));
|
||||
|
||||
@@ -503,7 +503,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
PolarDiagram polarDiagram = polarDiagramAndNotificationMessage.getA();
|
||||
String notificationMessage = polarDiagramAndNotificationMessage.getB();
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(new SimulationParametersImpl(null, polarDiagram, null,
|
||||
Simulator simulator = new SimulatorImpl(new SimulationParametersImpl(null, polarDiagram, null,
|
||||
null, SailingSimulatorConstants.ModeMeasured, true, true));
|
||||
Path gpsTrack = simulator.getLegGPSTrack(SimulatorServiceUtils.toSimulatorUISelection(requestData.selection));
|
||||
|
||||
@@ -582,7 +582,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
|
||||
SimulationParameters simulationParameters = new SimulationParametersImpl(null, polarDiagram, null, null,
|
||||
SailingSimulatorConstants.ModeMeasured, true, true);
|
||||
SailingSimulator sailingSimulator = new SailingSimulatorImpl(simulationParameters);
|
||||
Simulator sailingSimulator = new SimulatorImpl(simulationParameters);
|
||||
Path gpsWind = sailingSimulator.getLegGPSTrack(SimulatorServiceUtils
|
||||
.toSimulatorUISelection(requestData.selection));
|
||||
|
||||
@@ -658,7 +658,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
selectedRaceIndex = 0;
|
||||
}
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
Simulator simulator = new SimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
SailingSimulatorConstants.ModeMeasured, true, true));
|
||||
|
||||
return simulator.getLegsNames(selectedRaceIndex);
|
||||
@@ -667,7 +667,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
@Override
|
||||
public List<String> getRacesNames() {
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
Simulator simulator = new SimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
SailingSimulatorConstants.ModeMeasured, true, true));
|
||||
|
||||
return simulator.getRacesNames();
|
||||
@@ -680,10 +680,10 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
selectedRaceIndex = 0;
|
||||
}
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
Simulator simulator = new SimulatorImpl(new SimulationParametersImpl(null, null, null, null,
|
||||
SailingSimulatorConstants.ModeMeasured, true, true));
|
||||
|
||||
return simulator.getComeptitorsNames(selectedRaceIndex);
|
||||
return simulator.getCompetitorsNames(selectedRaceIndex);
|
||||
}
|
||||
|
||||
private void retreiveWindControlParameters(WindPatternDisplay pattern) {
|
||||
|
||||
+17
-9
@@ -26,12 +26,12 @@ import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PathType;
|
||||
import com.sap.sailing.simulator.PolarDiagram;
|
||||
import com.sap.sailing.simulator.SailingSimulator;
|
||||
import com.sap.sailing.simulator.Simulator;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.SimulationResults;
|
||||
import com.sap.sailing.simulator.impl.MaximumTurnTimes;
|
||||
import com.sap.sailing.simulator.impl.PolarDiagramGPS;
|
||||
import com.sap.sailing.simulator.impl.SailingSimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulationParametersImpl;
|
||||
import com.sap.sailing.simulator.impl.SparsePolarDataException;
|
||||
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
|
||||
@@ -181,14 +181,14 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<PathType, Path> getAllPaths(SimulationParameters simuPars) throws InterruptedException,
|
||||
public Map<PathType, Path> getAllPaths(SimulationParameters simulationParameters) throws InterruptedException,
|
||||
ExecutionException {
|
||||
|
||||
SailingSimulator simulator = new SailingSimulatorImpl(simuPars);
|
||||
Simulator simulator = new SimulatorImpl(simulationParameters);
|
||||
Map<PathType, Path> result = new HashMap<PathType, Path>();
|
||||
|
||||
FutureTask<Path> taskOmniscient = null;
|
||||
if (simuPars.showOmniscient()) {
|
||||
if (simulationParameters.showOmniscient()) {
|
||||
// schedule omniscient task
|
||||
taskOmniscient = new FutureTask<Path>(() -> simulator.getPath(PathType.OMNISCIENT, null));
|
||||
executor.execute(taskOmniscient);
|
||||
@@ -206,7 +206,7 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
|
||||
FutureTask<Path> taskOpportunistLeft = null;
|
||||
FutureTask<Path> taskOpportunistRight = null;
|
||||
if (simuPars.showOpportunist()) {
|
||||
if (simulationParameters.showOpportunist()) {
|
||||
// maximum turn times
|
||||
MaximumTurnTimes maxTurnTimes = new MaximumTurnTimes(task1TurnerLeft.get().getMaxTurnTime(), task1TurnerRight.get().getMaxTurnTime());
|
||||
|
||||
@@ -217,11 +217,19 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
executor.execute(taskOpportunistRight);
|
||||
|
||||
// collect opportunist results
|
||||
result.put(PathType.OPPORTUNIST_LEFT, taskOpportunistLeft.get());
|
||||
result.put(PathType.OPPORTUNIST_RIGHT, taskOpportunistRight.get());
|
||||
Path pathOpportunistLeft = taskOpportunistLeft.get();
|
||||
if (pathOpportunistLeft.getTurnCount() == 1) {
|
||||
pathOpportunistLeft = result.get(PathType.ONE_TURNER_LEFT);
|
||||
}
|
||||
result.put(PathType.OPPORTUNIST_LEFT, pathOpportunistLeft);
|
||||
Path pathOpportunistRight = taskOpportunistRight.get();
|
||||
if (pathOpportunistRight.getTurnCount() == 1) {
|
||||
pathOpportunistRight = result.get(PathType.ONE_TURNER_RIGHT);
|
||||
}
|
||||
result.put(PathType.OPPORTUNIST_RIGHT, pathOpportunistRight);
|
||||
}
|
||||
|
||||
if (simuPars.showOmniscient()) {
|
||||
if (simulationParameters.showOmniscient()) {
|
||||
// collect omniscient result (last, since usually slowest calculation)
|
||||
result.put(PathType.OMNISCIENT, taskOmniscient.get());
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.simulator.test;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,11 +14,12 @@ import com.sap.sailing.domain.common.Bearing;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PathType;
|
||||
import com.sap.sailing.simulator.PolarDiagram;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.impl.PolarDiagram49STG;
|
||||
import com.sap.sailing.simulator.impl.RectangularGrid;
|
||||
import com.sap.sailing.simulator.impl.SailingSimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulationParametersImpl;
|
||||
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
|
||||
import com.sap.sailing.simulator.windfield.WindControlParameters;
|
||||
@@ -56,15 +58,16 @@ public class SimulatorTest {
|
||||
|
||||
SimulationParameters param = new SimulationParametersImpl(course, pd, wf, null,
|
||||
SailingSimulatorConstants.ModeFreestyle, true, true);
|
||||
SailingSimulatorImpl sailingSim = new SailingSimulatorImpl(param);
|
||||
SimulatorImpl sailingSim = new SimulatorImpl(param);
|
||||
|
||||
// Map<String, Path> paths = sailingSim.getAllPathsForLeg(new SimulatorUISelectionImpl(0, 0, 0, 0));
|
||||
Map<String, Path> paths = sailingSim.getAllPaths();
|
||||
|
||||
// System.out.println("opportunistic path points: "+paths.get("2#Opportunist Left").getPathPoints().size());
|
||||
Assert.assertNotNull(paths.get("2#Opportunist Left").getPathPoints());
|
||||
// System.out.println("omnciscient path points: "+paths.get("1#Omniscient").getPathPoints().size());
|
||||
Assert.assertNotNull(paths.get("1#Omniscient").getPathPoints());
|
||||
Path pathOmniscient = sailingSim.getPath(PathType.OMNISCIENT, null);
|
||||
Path pathOpportunist = sailingSim.getPath(PathType.OPPORTUNIST_LEFT, null);
|
||||
Map<PathType, Path> paths = new HashMap<PathType, Path>();
|
||||
paths.put(PathType.OMNISCIENT, pathOmniscient);
|
||||
paths.put(PathType.OPPORTUNIST_LEFT, pathOpportunist);
|
||||
|
||||
Assert.assertNotNull(paths.get(PathType.OPPORTUNIST_LEFT).getPathPoints());
|
||||
Assert.assertNotNull(paths.get(PathType.OMNISCIENT).getPathPoints());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,4 +19,6 @@ public interface Path {
|
||||
List<TimedPositionWithSpeed> getTurns();
|
||||
|
||||
Path getEvenTimedPath(long timeStep);
|
||||
|
||||
int getTurnCount();
|
||||
}
|
||||
+5
-11
@@ -1,34 +1,28 @@
|
||||
package com.sap.sailing.simulator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.simulator.impl.MaximumTurnTimes;
|
||||
|
||||
|
||||
public interface SailingSimulator {
|
||||
public interface Simulator {
|
||||
|
||||
void setSimulationParameters(SimulationParameters params, SimulatorUISelection selection);
|
||||
|
||||
SimulationParameters getSimulationParameters();
|
||||
|
||||
Path getLegGPSTrack(SimulatorUISelection selection);
|
||||
|
||||
Path getPath(PathType pathType, MaximumTurnTimes maxTurnTimes);
|
||||
|
||||
Map<String, Path> getAllPaths();
|
||||
|
||||
Map<String, Path> getAllPathsForLeg(SimulatorUISelection selection);
|
||||
|
||||
Map<String, Path> getAllPathsEvenTimed(long millisecondsStep, SimulatorUISelection selection);
|
||||
|
||||
Path getRaceCourse();
|
||||
|
||||
List<String> getLegsNames(int selectedRaceIndex);
|
||||
|
||||
List<String> getRacesNames();
|
||||
|
||||
List<String> getCompetitorsNames(int selectedRaceIndex);
|
||||
|
||||
Path getLeg(int selectedCompetitorIndex, int selectedLegIndex);
|
||||
|
||||
List<String> getComeptitorsNames(int selectedRaceIndex);
|
||||
Path getLegGPSTrack(SimulatorUISelection selection);
|
||||
|
||||
}
|
||||
+6
-4
@@ -120,9 +120,11 @@ public class PathGeneratorOpportunistEuclidian extends PathGeneratorBase {
|
||||
turnloss = turnloss / timeStepScale;
|
||||
}
|
||||
|
||||
if ((maxTurnTimes.left > 0) || (maxTurnTimes.right > 0)) {
|
||||
this.maxLeft = (int) Math.floor((double) maxTurnTimes.left / (double) timeStep);
|
||||
this.maxRight = (int) Math.floor((double) maxTurnTimes.right / (double) timeStep);
|
||||
if (maxTurnTimes != null) {
|
||||
if ((maxTurnTimes.left > 0) || (maxTurnTimes.right > 0)) {
|
||||
this.maxLeft = (int) Math.floor((double) maxTurnTimes.left / (double) timeStep);
|
||||
this.maxRight = (int) Math.floor((double) maxTurnTimes.right / (double) timeStep);
|
||||
}
|
||||
}
|
||||
logger.info("Leg Direction: " + legType);
|
||||
|
||||
@@ -339,7 +341,7 @@ public class PathGeneratorOpportunistEuclidian extends PathGeneratorBase {
|
||||
path.addAll(rightPath.getPathPoints());
|
||||
}
|
||||
|
||||
return new PathImpl(path, wf);
|
||||
return new PathImpl(path, wf, getTurns());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ public class PathImpl implements Path, Serializable {
|
||||
private static final long serialVersionUID = -6354445155884413937L;
|
||||
private List<TimedPositionWithSpeed> pathPoints;
|
||||
private WindField windField;
|
||||
private int turnCount;
|
||||
private long maxTurnTime;
|
||||
|
||||
private static final double TRESHOLD_DEGREES = 25.0;
|
||||
@@ -35,19 +36,33 @@ public class PathImpl implements Path, Serializable {
|
||||
public PathImpl(List<TimedPositionWithSpeed> pointsList, WindField wf) {
|
||||
this.pathPoints = pointsList;
|
||||
this.windField = wf;
|
||||
this.turnCount = 0;
|
||||
this.maxTurnTime = 0;
|
||||
}
|
||||
|
||||
public PathImpl(List<TimedPositionWithSpeed> pointsList, WindField wf, long maxTurnTime) {
|
||||
this.pathPoints = pointsList;
|
||||
this.windField = wf;
|
||||
this.turnCount = 0;
|
||||
this.maxTurnTime = maxTurnTime;
|
||||
}
|
||||
|
||||
public PathImpl(List<TimedPositionWithSpeed> pointsList, WindField wf, int turnCount) {
|
||||
this.pathPoints = pointsList;
|
||||
this.windField = wf;
|
||||
this.turnCount = turnCount;
|
||||
this.maxTurnTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimedPositionWithSpeed> getPathPoints() {
|
||||
return this.pathPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTurnCount() {
|
||||
return this.turnCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPathPoints(List<TimedPositionWithSpeed> pointsList) {
|
||||
|
||||
-432
@@ -1,432 +0,0 @@
|
||||
package com.sap.sailing.simulator.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.MeterDistance;
|
||||
import com.sap.sailing.simulator.Grid;
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PathType;
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
import com.sap.sailing.simulator.SailingSimulator;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.SimulatorUISelection;
|
||||
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
|
||||
import com.sap.sailing.simulator.windfield.WindFieldGenerator;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
public class SailingSimulatorImpl implements SailingSimulator {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger("com.sap.sailing.simulator");
|
||||
|
||||
private SimulationParameters simulationParameters = null;
|
||||
private Path raceCourse = null;
|
||||
private PathGeneratorTracTrac pathGenerator = null;
|
||||
|
||||
private static final double WIND_SCALE = 4.5;
|
||||
|
||||
// proxy configuration
|
||||
private static final String LIVE_URI = "tcp://10.18.22.156:1520";
|
||||
|
||||
// no-proxy configuration
|
||||
// private static final String LIVE_URI = "tcp://germanmaster.traclive.dk:4400";
|
||||
|
||||
// proxy configuration
|
||||
private static final String STORED_URI = "tcp://10.18.22.156:1521";
|
||||
|
||||
// no-proxy configuration
|
||||
// private static final String STORED_URI = "tcp://germanmaster.traclive.dk:4401";
|
||||
|
||||
public SailingSimulatorImpl(SimulationParameters parameters) {
|
||||
this.simulationParameters = parameters;
|
||||
if (this.simulationParameters.getMode() == SailingSimulatorConstants.ModeMeasured) {
|
||||
this.initializePathGenerator(parameters, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSimulationParameters(SimulationParameters parameters, SimulatorUISelection selection) {
|
||||
|
||||
this.simulationParameters = parameters;
|
||||
this.initializePathGenerator(parameters, selection.getRaceIndex(), selection.getLegIndex(), selection.getCompetitorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimulationParameters getSimulationParameters() {
|
||||
return this.simulationParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath(PathType pathType, MaximumTurnTimes maxTurnTimes) {
|
||||
PathGeneratorTreeGrow genTreeGrow;
|
||||
PathGeneratorOpportunistEuclidian genOpportunistic;
|
||||
Path path = null;
|
||||
switch (pathType) {
|
||||
case OMNISCIENT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters(null, 0, null); // allow for arbitrary many turns
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_LEFT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("L", 1, null); // start left and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_RIGHT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("R", 1, null); // start right and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_LEFT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian(this.simulationParameters);
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, true);
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_RIGHT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian(this.simulationParameters);
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, false);
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Path> getAllPaths() {
|
||||
|
||||
Map<String, Path> allPaths = new HashMap<String, Path>();
|
||||
|
||||
//
|
||||
// Initialize WindFields boundary
|
||||
//
|
||||
WindFieldGenerator wf = this.simulationParameters.getWindField();
|
||||
int[] gridRes = wf.getGridResolution();
|
||||
Position[] gridArea = wf.getGridAreaGps();
|
||||
|
||||
LOGGER.info("showOmniscient : "+this.simulationParameters.showOmniscient());
|
||||
LOGGER.info("showOpportunist: "+this.simulationParameters.showOpportunist());
|
||||
|
||||
if (gridArea != null) {
|
||||
Grid bd = new CurvedGrid(gridArea[0], gridArea[1]);
|
||||
|
||||
// set base wind bearing
|
||||
wf.getWindParameters().baseWindBearing += bd.getSouth().getDegrees();
|
||||
// System.out.println("baseWindBearing: " + wf.getWindParameters().baseWindBearing);
|
||||
LOGGER.info("base wind: " + this.simulationParameters.getBoatPolarDiagram().getWind().getKnots() + " kn, "
|
||||
+ ((wf.getWindParameters().baseWindBearing) % 360.0) + "�");
|
||||
|
||||
// initialize interpolation table for getSpeedAtBearingOverGround, e.g. for what-if or for optimization on overground-grids
|
||||
// this.simulationParameters.getBoatPolarDiagram().setCurrent(null); // initialize
|
||||
|
||||
// set water current
|
||||
// this.simulationParameters.getBoatPolarDiagram().setCurrent(new KnotSpeedWithBearingImpl(0.0,new
|
||||
// DegreeBearingImpl((wf.getWindParameters().baseWindBearing+90.0)%360.0)));
|
||||
this.simulationParameters.getBoatPolarDiagram().setCurrent(
|
||||
new KnotSpeedWithBearingImpl(wf.getWindParameters().curSpeed, new DegreeBearingImpl(wf.getWindParameters().curBearing)));
|
||||
// this.simulationParameters.getBoatPolarDiagram().setCurrent(new KnotSpeedWithBearingImpl(2.0,new
|
||||
// DegreeBearingImpl((270.0)%360.0)));
|
||||
if (this.simulationParameters.getBoatPolarDiagram().getCurrent() != null) {
|
||||
LOGGER.info("water current: " + this.simulationParameters.getBoatPolarDiagram().getCurrent().getKnots() + " kn, "
|
||||
+ this.simulationParameters.getBoatPolarDiagram().getCurrent().getBearing().getDegrees() + "�");
|
||||
}
|
||||
|
||||
wf.setBoundary(bd);
|
||||
Position[][] positionGrid = bd.generatePositions(gridRes[0], gridRes[1], gridRes[2], gridRes[3]);
|
||||
wf.setPositionGrid(positionGrid);
|
||||
wf.generate(wf.getStartTime(), wf.getEndTime(), wf.getTimeStep());
|
||||
}
|
||||
|
||||
//
|
||||
// Start Simulation
|
||||
//
|
||||
|
||||
// get instance of heuristic searcher
|
||||
PathGeneratorTreeGrow genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters);
|
||||
|
||||
MaximumTurnTimes maxTurnTimes = new MaximumTurnTimes(1000000000, 1000000000);
|
||||
|
||||
// search best left-starting 1-turner
|
||||
genTreeGrow.setEvaluationParameters("L", 1, null);
|
||||
Path leftPath = genTreeGrow.getPath();
|
||||
PathCandidate leftBestCand = genTreeGrow.getBestCand();
|
||||
int left1TurnMiddle = 1000;
|
||||
long left1TurnTimestep = genTreeGrow.getUsedTimeStep();
|
||||
if (leftBestCand != null) {
|
||||
left1TurnMiddle = leftBestCand.getIndexOfTurnLR();
|
||||
maxTurnTimes.left = left1TurnMiddle * left1TurnTimestep;
|
||||
}
|
||||
|
||||
// search best right-starting 1-turner
|
||||
genTreeGrow.setEvaluationParameters("R", 1, null);
|
||||
Path rightPath = genTreeGrow.getPath();
|
||||
PathCandidate rightBestCand = genTreeGrow.getBestCand();
|
||||
int right1TurnMiddle = 1000;
|
||||
long right1TurnTimestep = genTreeGrow.getUsedTimeStep();
|
||||
if (rightBestCand != null) {
|
||||
right1TurnMiddle = rightBestCand.getIndexOfTurnRL();
|
||||
maxTurnTimes.right = right1TurnMiddle * right1TurnTimestep;
|
||||
}
|
||||
|
||||
Path optPath = null;
|
||||
if (this.simulationParameters.showOmniscient()) {
|
||||
// search best multi-turn course
|
||||
genTreeGrow.setEvaluationParameters(null, 0, null);
|
||||
optPath = genTreeGrow.getPath();
|
||||
}
|
||||
|
||||
Path oppPath = null;
|
||||
Path oppPathL = null;
|
||||
Path oppPathR = null;
|
||||
if (this.simulationParameters.showOpportunist()) {
|
||||
// evaluate opportunistic heuristic
|
||||
PathGeneratorOpportunistEuclidian genOpportunistic = new PathGeneratorOpportunistEuclidian(this.simulationParameters);
|
||||
// PathGeneratorOpportunistVMG genOpportunistic = new PathGeneratorOpportunistVMG(simulationParameters);
|
||||
|
||||
// left-starting opportunist
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, true);
|
||||
oppPathL = genOpportunistic.getPath();
|
||||
if (genOpportunistic.getTurns() == 1) {
|
||||
oppPathL = leftPath;
|
||||
}
|
||||
|
||||
// right-starting opportunist
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, false);
|
||||
oppPathR = genOpportunistic.getPath();
|
||||
if (genOpportunistic.getTurns() == 1) {
|
||||
oppPathR = rightPath;
|
||||
}
|
||||
|
||||
// compare left- & right-starting opportunists
|
||||
if (oppPathL.getPathPoints().get(oppPathL.getPathPoints().size() - 1).getTimePoint().asMillis() <= oppPathR.getPathPoints()
|
||||
.get(oppPathR.getPathPoints().size() - 1).getTimePoint().asMillis()) {
|
||||
oppPath = oppPathL;
|
||||
} else {
|
||||
oppPath = oppPathR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE: pathName convention is: sort-digit + "#" + path-name
|
||||
// The sort-digit defines the sorting of paths in webbrowser
|
||||
//
|
||||
|
||||
boolean plausCheck = false;
|
||||
// ensure omniscient is best avoiding artifactual results due to coarse-grainedness (finite timesteps) of course
|
||||
// generation
|
||||
if ((plausCheck)&&(this.simulationParameters.showOmniscient())) {
|
||||
if (leftPath.getPathPoints() != null) {
|
||||
if (leftPath.getPathPoints().get(leftPath.getPathPoints().size() - 1).getTimePoint().asMillis() <= optPath.getPathPoints()
|
||||
.get(optPath.getPathPoints().size() - 1).getTimePoint().asMillis()) {
|
||||
optPath = leftPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (rightPath.getPathPoints() != null) {
|
||||
if (rightPath.getPathPoints().get(rightPath.getPathPoints().size() - 1).getTimePoint().asMillis() <= optPath.getPathPoints()
|
||||
.get(optPath.getPathPoints().size() - 1).getTimePoint().asMillis()) {
|
||||
optPath = rightPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (oppPath != null) {
|
||||
if (oppPath.getPathPoints().get(oppPath.getPathPoints().size() - 1).getTimePoint().asMillis() <= optPath.getPathPoints()
|
||||
.get(optPath.getPathPoints().size() - 1).getTimePoint().asMillis()) {
|
||||
optPath = oppPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allPaths.put("5#1-Turner Right", rightPath);
|
||||
allPaths.put("4#1-Turner Left", leftPath);
|
||||
if (this.simulationParameters.showOpportunist()) {
|
||||
allPaths.put("3#Opportunist Right", oppPathR);
|
||||
allPaths.put("2#Opportunist Left", oppPathL);
|
||||
}
|
||||
if (this.simulationParameters.showOmniscient()) {
|
||||
allPaths.put("1#Omniscient", optPath);
|
||||
}
|
||||
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Path> getAllPathsForLeg(SimulatorUISelection selection) {
|
||||
|
||||
this.setSimulationParameters(this.simulationParameters, selection);
|
||||
|
||||
Map<String, Path> allPaths = new HashMap<String, Path>();
|
||||
Path gpsPath = null;
|
||||
Path gpsPathPoly = null;
|
||||
|
||||
Util.Pair<Map<String, Path>, Path> result = SimulatorUtils.readLegPathsFromResources(selection.getRaceIndex(), selection.getCompetitorIndex(),
|
||||
selection.getLegIndex());
|
||||
allPaths = result.getA();
|
||||
this.raceCourse = result.getB();
|
||||
|
||||
if (allPaths != null && allPaths.isEmpty() == false && allPaths.size() == 6) {
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
try {
|
||||
gpsPath = this.getFromResourcesOrDownload("7#GPS Track", selection.getRaceIndex(), selection.getCompetitorIndex(), selection.getLegIndex());
|
||||
gpsPathPoly = this.getFromResourcesOrDownload("6#GPS Poly", selection.getRaceIndex(), selection.getCompetitorIndex(), selection.getLegIndex());
|
||||
this.raceCourse = this.getFromResourcesOrDownload("raceCourse", selection.getRaceIndex(), selection.getCompetitorIndex(),
|
||||
selection.getLegIndex());
|
||||
} catch (Exception e) {
|
||||
LOGGER.severe(e.getMessage());
|
||||
}
|
||||
|
||||
allPaths.put("6#GPS Poly", gpsPathPoly);
|
||||
allPaths.put("7#GPS Track", gpsPath);
|
||||
|
||||
allPaths.putAll(SimulatorUtils.getSimulationPaths(this.simulationParameters, gpsPath, this.raceCourse));
|
||||
|
||||
if (this.simulationParameters.getMode() == SailingSimulatorConstants.ModeMeasured) {
|
||||
SimulatorUtils.saveLegPathsToFiles(allPaths, this.raceCourse, selection.getRaceIndex(), selection.getCompetitorIndex(), selection.getLegIndex());
|
||||
}
|
||||
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getRaceCourse() {
|
||||
return this.raceCourse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Path> getAllPathsEvenTimed(long millisecondsStep, SimulatorUISelection selection) {
|
||||
|
||||
Map<String, Path> allTimedPaths = new TreeMap<String, Path>();
|
||||
|
||||
Map<String, Path> allPaths = selection == null ? this.getAllPaths() : this.getAllPathsForLeg(selection);
|
||||
|
||||
for (Entry<String, Path> entry : allPaths.entrySet()) {
|
||||
|
||||
String pathName = entry.getKey();
|
||||
Path value = entry.getValue();
|
||||
|
||||
if (pathName.equals("7#GPS Track")) {
|
||||
allTimedPaths.put(pathName, value);
|
||||
} else {
|
||||
allTimedPaths.put(pathName, value.getEvenTimedPath(millisecondsStep));
|
||||
}
|
||||
}
|
||||
|
||||
return allTimedPaths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getLegGPSTrack(SimulatorUISelection selection) {
|
||||
//
|
||||
String fileName = SimulatorUtils.getFileName(selection.getRaceIndex(), selection.getCompetitorIndex(), selection.getLegIndex(), "7#GPS Track");
|
||||
|
||||
Path path = (Path) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (path == null) {
|
||||
System.err.println("[ERROR][SailingSimulatorImpl][readPathsFromResources] Cannot de-serialize path from resources/7#GPS Track.dat");
|
||||
LOGGER.warning("[ERROR][SailingSimulatorImpl][readPathsFromResources] Cannot de-serialize path from resources/7#GPS Track.dat");
|
||||
|
||||
this.pathGenerator.setSelectionParameters(selection.getLegIndex(), selection.getCompetitorIndex());
|
||||
path = this.pathGenerator.getPath();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<String> getLegsNames(int selectedRaceIndex) {
|
||||
|
||||
this.setSimulationParameters(this.simulationParameters, new SimulatorUISelectionImpl(0, selectedRaceIndex, 0, 0));
|
||||
|
||||
List<String> legsNames = null;
|
||||
String fileName = SimulatorUtils.getRaceID(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex)) + "_" + SimulatorUtils.LEGSNAMES_DAT;
|
||||
|
||||
legsNames = (List<String>) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (legsNames != null && legsNames.isEmpty() == false) {
|
||||
return legsNames;
|
||||
}
|
||||
|
||||
legsNames = this.pathGenerator.getLegsNames();
|
||||
|
||||
SimulatorUtils.saveStringListToFiles(legsNames, fileName);
|
||||
|
||||
return legsNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRacesNames() {
|
||||
|
||||
List<String> racesNames = new ArrayList<String>();
|
||||
|
||||
for (RaceProperties raceInfo : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
racesNames.add(raceInfo.getName());
|
||||
}
|
||||
|
||||
return racesNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getLeg(int selectedCompetitorIndex, int selectedLegIndex) {
|
||||
|
||||
this.pathGenerator.setSelectionParameters(selectedLegIndex, selectedCompetitorIndex);
|
||||
return this.pathGenerator.getPath();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<String> getComeptitorsNames(int selectedRaceIndex) {
|
||||
|
||||
this.setSimulationParameters(this.simulationParameters, new SimulatorUISelectionImpl(0, selectedRaceIndex, 0, 0));
|
||||
|
||||
List<String> competitorsNames = null;
|
||||
String fileName = SimulatorUtils.getRaceID(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex)) + "_" + SimulatorUtils.COMPETITORSNAMES_DAT;
|
||||
|
||||
competitorsNames = (List<String>) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (competitorsNames != null && competitorsNames.isEmpty() == false) {
|
||||
return competitorsNames;
|
||||
}
|
||||
|
||||
competitorsNames = this.pathGenerator.getComeptitorsNames();
|
||||
|
||||
SimulatorUtils.saveStringListToFiles(competitorsNames, fileName);
|
||||
|
||||
return competitorsNames;
|
||||
}
|
||||
|
||||
private void initializePathGenerator(SimulationParameters parameters, int selectedRaceIndex, int selectedLegIndex, int selectedCompetitorIndex) {
|
||||
|
||||
this.pathGenerator = new PathGeneratorTracTrac(parameters);
|
||||
this.pathGenerator.setEvaluationParameters(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex), LIVE_URI, STORED_URI, WIND_SCALE);
|
||||
this.pathGenerator.setSelectionParameters(selectedLegIndex, selectedCompetitorIndex);
|
||||
}
|
||||
|
||||
private Path getFromResourcesOrDownload(String pathName, int selectedRaceIndex, int selectedCompetitorIndex, int selectedLegIndex) throws Exception {
|
||||
|
||||
String fileName = SimulatorUtils.getFileName(selectedRaceIndex, selectedCompetitorIndex, selectedLegIndex, pathName);
|
||||
|
||||
Path path = (Path) SimulatorUtils.readObjectFromResources(fileName);
|
||||
if (path == null) {
|
||||
if (pathName.equals("6#GPS Poly")) {
|
||||
path = this.pathGenerator.getPathPolyline(new MeterDistance(4.88));
|
||||
} else if (pathName.equals("7#GPS Track")) {
|
||||
path = this.pathGenerator.getPath();
|
||||
} else if (pathName.equals("raceCourse")) {
|
||||
path = this.pathGenerator.getRaceCourse();
|
||||
} else {
|
||||
throw new Exception("Unknown path name!");
|
||||
}
|
||||
SimulatorUtils.saveToFile(path, SimulatorUtils.getPathPrefix() + "\\resources\\" + fileName);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.sap.sailing.simulator.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.simulator.Path;
|
||||
import com.sap.sailing.simulator.PathType;
|
||||
import com.sap.sailing.simulator.RaceProperties;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.Simulator;
|
||||
import com.sap.sailing.simulator.SimulatorUISelection;
|
||||
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
|
||||
|
||||
public class SimulatorImpl implements Simulator {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger("com.sap.sailing.simulator");
|
||||
|
||||
private SimulationParameters simulationParameters = null;
|
||||
private Path raceCourse = null;
|
||||
private PathGeneratorTracTrac pathGenerator = null;
|
||||
|
||||
public SimulatorImpl(SimulationParameters parameters) {
|
||||
this.simulationParameters = parameters;
|
||||
if (this.simulationParameters.getMode() == SailingSimulatorConstants.ModeMeasured) {
|
||||
this.initializePathGenerator(parameters, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSimulationParameters(SimulationParameters parameters, SimulatorUISelection selection) {
|
||||
|
||||
this.simulationParameters = parameters;
|
||||
this.initializePathGenerator(parameters, selection.getRaceIndex(), selection.getLegIndex(), selection.getCompetitorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimulationParameters getSimulationParameters() {
|
||||
return this.simulationParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath(PathType pathType, MaximumTurnTimes maxTurnTimes) {
|
||||
PathGeneratorTreeGrow genTreeGrow;
|
||||
PathGeneratorOpportunistEuclidian genOpportunistic;
|
||||
Path path = null;
|
||||
switch (pathType) {
|
||||
case OMNISCIENT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters(null, 0, null); // allow for arbitrary many turns
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_LEFT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("L", 1, null); // start left and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_RIGHT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("R", 1, null); // start right and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_LEFT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, true); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_RIGHT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(maxTurnTimes, false); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getRaceCourse() {
|
||||
return this.raceCourse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getLegGPSTrack(SimulatorUISelection selection) {
|
||||
//
|
||||
String fileName = SimulatorUtils.getFileName(selection.getRaceIndex(), selection.getCompetitorIndex(), selection.getLegIndex(), "7#GPS Track");
|
||||
|
||||
Path path = (Path) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (path == null) {
|
||||
System.err.println("[ERROR][SailingSimulatorImpl][readPathsFromResources] Cannot de-serialize path from resources/7#GPS Track.dat");
|
||||
LOGGER.warning("[ERROR][SailingSimulatorImpl][readPathsFromResources] Cannot de-serialize path from resources/7#GPS Track.dat");
|
||||
|
||||
this.pathGenerator.setSelectionParameters(selection.getLegIndex(), selection.getCompetitorIndex());
|
||||
path = this.pathGenerator.getPath();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<String> getLegsNames(int selectedRaceIndex) {
|
||||
|
||||
this.setSimulationParameters(this.simulationParameters, new SimulatorUISelectionImpl(0, selectedRaceIndex, 0, 0));
|
||||
|
||||
List<String> legsNames = null;
|
||||
String fileName = SimulatorUtils.getRaceID(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex)) + "_" + SimulatorUtils.LEGSNAMES_DAT;
|
||||
|
||||
legsNames = (List<String>) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (legsNames != null && legsNames.isEmpty() == false) {
|
||||
return legsNames;
|
||||
}
|
||||
|
||||
legsNames = this.pathGenerator.getLegsNames();
|
||||
|
||||
SimulatorUtils.saveStringListToFiles(legsNames, fileName);
|
||||
|
||||
return legsNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRacesNames() {
|
||||
|
||||
List<String> racesNames = new ArrayList<String>();
|
||||
|
||||
for (RaceProperties raceInfo : ConfigurationManager.INSTANCE.getRacesInfo()) {
|
||||
racesNames.add(raceInfo.getName());
|
||||
}
|
||||
|
||||
return racesNames;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<String> getCompetitorsNames(int selectedRaceIndex) {
|
||||
|
||||
this.setSimulationParameters(this.simulationParameters, new SimulatorUISelectionImpl(0, selectedRaceIndex, 0, 0));
|
||||
|
||||
List<String> competitorsNames = null;
|
||||
String fileName = SimulatorUtils.getRaceID(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex)) + "_" + SimulatorUtils.COMPETITORSNAMES_DAT;
|
||||
|
||||
competitorsNames = (List<String>) SimulatorUtils.readObjectFromResources("resources/" + fileName);
|
||||
if (competitorsNames != null && competitorsNames.isEmpty() == false) {
|
||||
return competitorsNames;
|
||||
}
|
||||
|
||||
competitorsNames = this.pathGenerator.getComeptitorsNames();
|
||||
|
||||
SimulatorUtils.saveStringListToFiles(competitorsNames, fileName);
|
||||
|
||||
return competitorsNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getLeg(int selectedCompetitorIndex, int selectedLegIndex) {
|
||||
|
||||
this.pathGenerator.setSelectionParameters(selectedLegIndex, selectedCompetitorIndex);
|
||||
return this.pathGenerator.getPath();
|
||||
}
|
||||
|
||||
private void initializePathGenerator(SimulationParameters parameters, int selectedRaceIndex, int selectedLegIndex, int selectedCompetitorIndex) {
|
||||
|
||||
this.pathGenerator = new PathGeneratorTracTrac(parameters);
|
||||
//this.pathGenerator.setEvaluationParameters(ConfigurationManager.INSTANCE.getRaceURL(selectedRaceIndex), LIVE_URI, STORED_URI, WIND_SCALE);
|
||||
this.pathGenerator.setSelectionParameters(selectedLegIndex, selectedCompetitorIndex);
|
||||
}
|
||||
|
||||
/*private Path getFromResourcesOrDownload(String pathName, int selectedRaceIndex, int selectedCompetitorIndex, int selectedLegIndex) throws Exception {
|
||||
|
||||
String fileName = SimulatorUtils.getFileName(selectedRaceIndex, selectedCompetitorIndex, selectedLegIndex, pathName);
|
||||
|
||||
Path path = (Path) SimulatorUtils.readObjectFromResources(fileName);
|
||||
if (path == null) {
|
||||
if (pathName.equals("6#GPS Poly")) {
|
||||
path = this.pathGenerator.getPathPolyline(new MeterDistance(4.88));
|
||||
} else if (pathName.equals("7#GPS Track")) {
|
||||
path = this.pathGenerator.getPath();
|
||||
} else if (pathName.equals("raceCourse")) {
|
||||
path = this.pathGenerator.getRaceCourse();
|
||||
} else {
|
||||
throw new Exception("Unknown path name!");
|
||||
}
|
||||
SimulatorUtils.saveToFile(path, SimulatorUtils.getPathPrefix() + "\\resources\\" + fileName);
|
||||
}
|
||||
|
||||
return path;
|
||||
}*/
|
||||
}
|
||||
Reference in new issue
Block a user