Merge branch 'master' into HEAD

# Conflicts:
#	racevisionGame/src/main/java/mock/app/Event.java
main
Fan-Wu Yang 8 years ago
commit 3760a43cfc

@ -107,12 +107,12 @@ public class Event {
//Read XML files. //Read XML files.
try { try {
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
//this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8)); this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
this.raceXML = RaceXMLCreator.alterRaceToWind(this.raceXML, XMLFileType.Contents, 300, false);
if(mapIndex==4){ if(mapIndex==4){
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8), 1000, 5000); this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8), 1000, 5000);
} else {
this.raceXML = RaceXMLCreator.alterRaceToWind(this.raceXML, XMLFileType.Contents, 300, false);
} }
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8); this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
@ -148,14 +148,23 @@ public class Event {
Bearing.fromDegrees(225), Bearing.fromDegrees(225),
12 12
); );
MockRace mockRace = new MockRace(
boatDataSource,
raceDataSource,
regattaDataSource,
this.boatPolars,
Constants.RaceTimeScale,
windGenerator );
if(mapIndex==4){
mockRace.setRacePreStartTime(1000);
mockRace.setRacePreparatoryTime(5000);
}
RaceLogic newRace = new RaceLogic( RaceLogic newRace = new RaceLogic(
new MockRace( mockRace,
boatDataSource,
raceDataSource,
regattaDataSource,
this.boatPolars,
Constants.RaceTimeScale,
windGenerator ),
this.latestMessages, this.latestMessages,
this.compositeCommand); this.compositeCommand);

@ -63,7 +63,9 @@ public class MockRace extends RaceState {
private ActiveObserverCommand activeObserverCommand; private ActiveObserverCommand activeObserverCommand;
private long racePreStartTime = Constants.RacePreStartTime;
private long racePreparatoryTime = Constants.RacePreparatoryTime;
/** /**
* Constructs a race object with a given RaceDataSource, BoatDataSource, and RegattaDataSource and sends events to the given mockOutput. * Constructs a race object with a given RaceDataSource, BoatDataSource, and RegattaDataSource and sends events to the given mockOutput.
@ -162,15 +164,15 @@ public class MockRace extends RaceState {
long timeToStart = - this.getRaceClock().getDurationMilli(); long timeToStart = - this.getRaceClock().getDurationMilli();
if (timeToStart > Constants.RacePreStartTime) { if (timeToStart > racePreStartTime) {
//Time > 3 minutes is the prestart period. //Time > 3 minutes is the prestart period.
this.setRaceStatusEnum(RaceStatusEnum.PRESTART); this.setRaceStatusEnum(RaceStatusEnum.PRESTART);
} else if ((timeToStart <= Constants.RacePreStartTime) && (timeToStart >= Constants.RacePreparatoryTime)) { } else if ((timeToStart <= racePreStartTime) && (timeToStart >= racePreparatoryTime)) {
//Time between [1, 3] minutes is the warning period. //Time between [1, 3] minutes is the warning period.
this.setRaceStatusEnum(RaceStatusEnum.WARNING); this.setRaceStatusEnum(RaceStatusEnum.WARNING);
} else if ((timeToStart <= Constants.RacePreparatoryTime) && (timeToStart > 0)) { } else if ((timeToStart <= racePreparatoryTime) && (timeToStart > 0)) {
//Time between (0, 1] minutes is the preparatory period. //Time between (0, 1] minutes is the preparatory period.
this.setRaceStatusEnum(RaceStatusEnum.PREPARATORY); this.setRaceStatusEnum(RaceStatusEnum.PREPARATORY);
@ -183,6 +185,13 @@ public class MockRace extends RaceState {
} }
public void setRacePreStartTime(long racePreStartTime) {
this.racePreStartTime = racePreStartTime;
}
public void setRacePreparatoryTime(long racePreparatoryTime) {
this.racePreparatoryTime = racePreparatoryTime;
}
/** /**
* Sets the status of all boats in the race to RACING. * Sets the status of all boats in the race to RACING.

Loading…
Cancel
Save