mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Introduced pre live race in context, improved logging
This commit is contained in:
1 parent
f5264bd436
commit
1fd8df4709
24 files changed
+178
-99
No files matched your search
+5
-3
@@ -15,11 +15,13 @@ public interface AutoPlayContext {
|
||||
|
||||
EventDTO getEvent();
|
||||
|
||||
public RegattaAndRaceIdentifier getLifeRace();
|
||||
RegattaAndRaceIdentifier getPreLiveRace();
|
||||
|
||||
public RegattaAndRaceIdentifier getLastRace();
|
||||
RegattaAndRaceIdentifier getLiveRace();
|
||||
|
||||
public void setCurrentLifeRace(RegattaAndRaceIdentifier lifeRace);
|
||||
RegattaAndRaceIdentifier getLastRace();
|
||||
|
||||
void updateLiveRace(RegattaAndRaceIdentifier currentPreLifeRace, RegattaAndRaceIdentifier currentLifeRace);
|
||||
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> getAutoplaySettings();
|
||||
|
||||
|
||||
+20
-11
@@ -11,8 +11,9 @@ public class AutoPlayContextImpl implements AutoPlayContext {
|
||||
private AutoPlayConfiguration configuration;
|
||||
private AutoPlayContextDefinition contextDefinition;
|
||||
private EventDTO event;
|
||||
private RegattaAndRaceIdentifier lifeRace;
|
||||
private RegattaAndRaceIdentifier liveRace;
|
||||
private RegattaAndRaceIdentifier lastRace;
|
||||
private RegattaAndRaceIdentifier preLiveRace;
|
||||
private AutoplayPerspectiveLifecycle autoplayLifecycle;
|
||||
private PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> autoplaySettings;
|
||||
|
||||
@@ -46,20 +47,18 @@ public class AutoPlayContextImpl implements AutoPlayContext {
|
||||
return contextDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaAndRaceIdentifier getLifeRace() {
|
||||
return lifeRace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentLifeRace(RegattaAndRaceIdentifier lifeRace) {
|
||||
if (this.lifeRace != null) {
|
||||
if (!this.lifeRace.equals(lifeRace)) {
|
||||
this.lastRace = this.lifeRace;
|
||||
GWT.log("lastrace was " + lastRace + " liferace is now " + lifeRace);
|
||||
public void updateLiveRace(RegattaAndRaceIdentifier currentPreLifeRace,
|
||||
RegattaAndRaceIdentifier currentLiveRace) {
|
||||
if (this.liveRace != null) {
|
||||
if (!this.liveRace.equals(liveRace)) {
|
||||
this.lastRace = this.liveRace;
|
||||
GWT.log("lastrace was " + lastRace + " liferace is now " + liveRace);
|
||||
}
|
||||
}
|
||||
this.lifeRace = lifeRace;
|
||||
this.preLiveRace = currentPreLifeRace;
|
||||
this.liveRace = currentLiveRace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,6 +76,16 @@ public class AutoPlayContextImpl implements AutoPlayContext {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaAndRaceIdentifier getLiveRace() {
|
||||
return liveRace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaAndRaceIdentifier getPreLiveRace() {
|
||||
return preLiveRace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaAndRaceIdentifier getLastRace() {
|
||||
return lastRace;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class IdleOverallLeaderBoardNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public IdleOverallLeaderBoardNode(AutoPlayClientFactory cf) {
|
||||
|
||||
super(IdleOverallLeaderBoardNode.class.getName());
|
||||
this.cf = cf;
|
||||
|
||||
}
|
||||
|
||||
+8
-14
@@ -23,8 +23,10 @@ public class IdleRaceLeaderboard extends FiresPlaceNode {
|
||||
private final Timer leaderboardTimer;
|
||||
|
||||
public IdleRaceLeaderboard(AutoPlayClientFactory cf) {
|
||||
super(IdleRaceLeaderboard.class.getName());
|
||||
this.cf = cf;
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> settings = cf.getAutoPlayCtx().getAutoplaySettings();
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> settings = cf.getAutoPlayCtx()
|
||||
.getAutoplaySettings();
|
||||
leaderboardTimer = new Timer(PlayModes.Live,
|
||||
/* delayBetweenAutoAdvancesInMilliseconds */ LeaderboardEntryPoint.DEFAULT_REFRESH_INTERVAL_MILLIS);
|
||||
leaderboardTimer
|
||||
@@ -32,36 +34,28 @@ public class IdleRaceLeaderboard extends FiresPlaceNode {
|
||||
leaderboardTimer.setRefreshInterval(REFRESH_INTERVAL_IN_MILLIS_LEADERBOARD);
|
||||
}
|
||||
|
||||
|
||||
public void onStart() {
|
||||
leaderboardTimer.play();
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> settings = cf.getAutoPlayCtx().getAutoplaySettings();
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> settings = cf.getAutoPlayCtx()
|
||||
.getAutoplaySettings();
|
||||
AutoplayPerspectiveLifecycle autoplayLifecycle = cf.getAutoPlayCtx().getAutoplayLifecycle();
|
||||
boolean withFullscreenButton = settings.getPerspectiveOwnSettings().isFullscreen();
|
||||
PerspectiveCompositeSettings<LeaderboardWithHeaderPerspectiveSettings> leaderboardSettings = settings
|
||||
.findSettingsByComponentId(autoplayLifecycle.getLeaderboardLifecycle().getComponentId());
|
||||
|
||||
|
||||
StringMessages stringMessages = StringMessages.INSTANCE;
|
||||
|
||||
LeaderboardWithHeaderPerspective leaderboardPerspective = new LeaderboardWithHeaderPerspective(null, null,
|
||||
autoplayLifecycle.getLeaderboardLifecycle(), leaderboardSettings, cf.getSailingService(),
|
||||
cf.getUserService(),
|
||||
AutoplayHelper.asyncActionsExecutor, new CompetitorSelectionModel(/* hasMultiSelection */ true),
|
||||
leaderboardTimer, cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), cf.getErrorReporter(),
|
||||
stringMessages,
|
||||
cf.getUserService(), AutoplayHelper.asyncActionsExecutor,
|
||||
new CompetitorSelectionModel(/* hasMultiSelection */ true), leaderboardTimer,
|
||||
cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), cf.getErrorReporter(), stringMessages,
|
||||
withFullscreenButton);
|
||||
setPlaceToGo(new LeaderboardPlace(leaderboardPerspective));
|
||||
|
||||
StrippedLeaderboardDTO leaderboard = AutoplayHelper.getSelectedLeaderboard(cf.getAutoPlayCtx().getEvent(),
|
||||
cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName());
|
||||
String title = stringMessages.leaderboard() + ": "
|
||||
+ (leaderboard.getDisplayName() == null ? leaderboard.name : leaderboard.getDisplayName());
|
||||
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(title, ""));
|
||||
|
||||
firePlaceChangeAndStartTimer();
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class IdleUpNextNode extends FiresPlaceNode {
|
||||
// */1000l);
|
||||
|
||||
public IdleUpNextNode(AutoPlayClientFactory cf) {
|
||||
|
||||
super(IdleUpNextNode.class.getName());
|
||||
this.cf = cf;
|
||||
place = new IdleUpNextPlace();
|
||||
}
|
||||
|
||||
+7
-7
@@ -37,7 +37,7 @@ public class LiveRaceBoardNode extends FiresPlaceNode implements RaceTimesInfoPr
|
||||
|
||||
|
||||
public LiveRaceBoardNode(AutoPlayClientFactory cf) {
|
||||
|
||||
super(LiveRaceBoardNode.class.getName());
|
||||
this.cf = cf;
|
||||
SailingServiceAsync sailingService = cf.getSailingService();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LiveRaceBoardNode extends FiresPlaceNode implements RaceTimesInfoPr
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
raceTimesInfoProvider.addRaceIdentifier(cf.getAutoPlayCtx().getLifeRace(), true);
|
||||
raceTimesInfoProvider.addRaceIdentifier(cf.getAutoPlayCtx().getLiveRace(), true);
|
||||
|
||||
PerspectiveCompositeSettings<AutoplayPerspectiveOwnSettings> settings = cf.getAutoPlayCtx().getAutoplaySettings();
|
||||
AutoplayPerspectiveLifecycle autoplayLifecycle = cf.getAutoPlayCtx().getAutoplayLifecycle();
|
||||
@@ -72,15 +72,15 @@ public class LiveRaceBoardNode extends FiresPlaceNode implements RaceTimesInfoPr
|
||||
autoplayLifecycle.getRaceboardLifecycle(), raceboardSettings, sailingService, mediaService,
|
||||
userService, AutoplayHelper.asyncActionsExecutor, result.getCompetitorAndTheirBoats(),
|
||||
raceboardTimer,
|
||||
cf.getAutoPlayCtx().getLifeRace(), cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(),
|
||||
cf.getAutoPlayCtx().getLiveRace(), cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(),
|
||||
/** leaderboardGroupName */
|
||||
null, /** eventId */
|
||||
null, cf.getErrorReporter(), StringMessages.INSTANCE, null, raceTimesInfoProvider, true, false);
|
||||
setPlaceToGo(new LiveRaceWithRaceboardPlace(raceboardPerspective));
|
||||
firePlaceChangeAndStartTimer();
|
||||
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName()));
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLiveRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLiveRace().getRaceName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,8 +89,8 @@ public class LiveRaceBoardNode extends FiresPlaceNode implements RaceTimesInfoPr
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent("", ""));
|
||||
}
|
||||
};
|
||||
sailingService.getRaceboardData(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName(), cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), null,
|
||||
sailingService.getRaceboardData(cf.getAutoPlayCtx().getLiveRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLiveRace().getRaceName(), cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), null,
|
||||
null, raceBoardDataCallback);
|
||||
};
|
||||
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ public class LiveRaceWithRacemapNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public LiveRaceWithRacemapNode(AutoPlayClientFactory cf) {
|
||||
|
||||
super(LiveRaceWithRacemapNode.class.getName());
|
||||
this.cf = cf;
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class LiveRaceWithRacemapNode extends FiresPlaceNode {
|
||||
public void onStart() {
|
||||
RaceMapHelper.create(cf.getSailingService(), cf.getErrorReporter(),
|
||||
cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), cf.getAutoPlayCtx().getContextDefinition().getEventId(),
|
||||
cf.getAutoPlayCtx().getEvent(), cf.getEventBus(), cf.getDispatch(), cf.getAutoPlayCtx().getLifeRace(),
|
||||
cf.getAutoPlayCtx().getEvent(), cf.getEventBus(), cf.getDispatch(), cf.getAutoPlayCtx().getLiveRace(),
|
||||
new AsyncCallback<RVWrapper>() {
|
||||
|
||||
@Override
|
||||
@@ -38,8 +38,8 @@ public class LiveRaceWithRacemapNode extends FiresPlaceNode {
|
||||
place.setRaceMap(result.raceboardPerspective, result.csel);
|
||||
setPlaceToGo(place);
|
||||
firePlaceChangeAndStartTimer();
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName()));
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLiveRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLiveRace().getRaceName()));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
+5
-4
@@ -6,10 +6,11 @@ import com.sap.sailing.gwt.autoplay.client.nodes.base.FiresPlaceNode;
|
||||
import com.sap.sailing.gwt.autoplay.client.places.screens.preliveraceloop.leaderboard.AbstractPreRaceLeaderBoardWithImagePlace;
|
||||
import com.sap.sailing.gwt.autoplay.client.places.screens.preliveraceloop.leaderboard.PreRaceLeaderBoardWithCompetitorPlace;
|
||||
|
||||
public class PreLeaderBoardWithCompetitorsNode extends FiresPlaceNode {
|
||||
public class PreLiveRaceLeaderBoardWithCompetitorsNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public PreLeaderBoardWithCompetitorsNode(AutoPlayClientFactory cf) {
|
||||
public PreLiveRaceLeaderBoardWithCompetitorsNode(AutoPlayClientFactory cf) {
|
||||
super(PreLiveRaceLeaderBoardWithCompetitorsNode.class.getName());
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
@@ -17,7 +18,7 @@ public class PreLeaderBoardWithCompetitorsNode extends FiresPlaceNode {
|
||||
AbstractPreRaceLeaderBoardWithImagePlace place = new PreRaceLeaderBoardWithCompetitorPlace();
|
||||
setPlaceToGo(place);
|
||||
firePlaceChangeAndStartTimer();
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName()));
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getPreLiveRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getPreLiveRace().getRaceName()));
|
||||
};
|
||||
}
|
||||
+8
-5
@@ -12,10 +12,11 @@ import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeade
|
||||
import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeaderbordAction;
|
||||
import com.sap.sse.gwt.dispatch.shared.commands.ResultWithTTL;
|
||||
|
||||
public class PreRaceWithRacemapNode extends FiresPlaceNode {
|
||||
public class PreLiveRaceWithRacemapNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public PreRaceWithRacemapNode(AutoPlayClientFactory cf) {
|
||||
public PreLiveRaceWithRacemapNode(AutoPlayClientFactory cf) {
|
||||
super(PreLiveRaceWithRacemapNode.class.getName());
|
||||
this.cf = cf;
|
||||
|
||||
}
|
||||
@@ -24,7 +25,8 @@ public class PreRaceWithRacemapNode extends FiresPlaceNode {
|
||||
public void onStart() {
|
||||
RaceMapHelper.create(cf.getSailingService(), cf.getErrorReporter(),
|
||||
cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName(), cf.getAutoPlayCtx().getContextDefinition().getEventId(),
|
||||
cf.getAutoPlayCtx().getEvent(), cf.getEventBus(), cf.getDispatch(),cf.getAutoPlayCtx().getLifeRace(), new AsyncCallback<RVWrapper>() {
|
||||
cf.getAutoPlayCtx().getEvent(), cf.getEventBus(), cf.getDispatch(),
|
||||
cf.getAutoPlayCtx().getPreLiveRace(), new AsyncCallback<RVWrapper>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
@@ -57,8 +59,9 @@ public class PreRaceWithRacemapNode extends FiresPlaceNode {
|
||||
place.setURL(cf.getAutoPlayCtx().getEvent().getOfficialWebsiteURL());
|
||||
setPlaceToGo(place);
|
||||
getBus().fireEvent(
|
||||
new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName()));
|
||||
new AutoPlayHeaderEvent(
|
||||
cf.getAutoPlayCtx().getPreLiveRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getPreLiveRace().getRaceName()));
|
||||
firePlaceChangeAndStartTimer();
|
||||
|
||||
}
|
||||
+1
@@ -15,6 +15,7 @@ public class RaceEndWithCompetitorsBoatsNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public RaceEndWithCompetitorsBoatsNode(AutoPlayClientFactory cf) {
|
||||
super(RaceEndWithCompetitorsBoatsNode.class.getName());
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ public class RaceEndWithCompetitorsFlagsNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public RaceEndWithCompetitorsFlagsNode(AutoPlayClientFactory cf) {
|
||||
super(RaceEndWithCompetitorsFlagsNode.class.getName());
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes;
|
||||
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
|
||||
import com.sap.sailing.gwt.autoplay.client.events.FailureEvent;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.AutoPlayNode;
|
||||
@@ -11,12 +12,14 @@ public class RootNodeClassic extends RootNodeBase {
|
||||
private final AutoPlayNode live;
|
||||
|
||||
public RootNodeClassic(AutoPlayClientFactory cf) {
|
||||
super(cf);
|
||||
super(RaceEndWithCompetitorsFlagsNode.class.getName(), cf);
|
||||
this.idle = new IdleRaceLeaderboard(cf);
|
||||
this.live = new LiveRaceBoardNode(cf);
|
||||
}
|
||||
|
||||
protected boolean processStateTransition(RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
protected boolean processStateTransition(RegattaAndRaceIdentifier currentPreLiveRace,
|
||||
RegattaAndRaceIdentifier currentLiveRace, RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
getClientFactory().getAutoPlayCtx().updateLiveRace(currentPreLiveRace, currentLiveRace);
|
||||
switch (goingTo) {
|
||||
case IDLE:
|
||||
case AFTER_LIVE:
|
||||
|
||||
+12
-6
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes;
|
||||
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
|
||||
import com.sap.sailing.gwt.autoplay.client.events.FailureEvent;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.AutoPlayLoopNode;
|
||||
@@ -17,11 +18,14 @@ public class RootNodeSixtyInch extends RootNodeBase {
|
||||
protected boolean afterRaceFinished = true;
|
||||
|
||||
public RootNodeSixtyInch(AutoPlayClientFactory cf) {
|
||||
super(cf);
|
||||
this.idleLoop = new AutoPlayLoopNode(30,new IdleUpNextNode(cf),new IdleOverallLeaderBoardNode(cf));
|
||||
this.preLiveRaceLoop = new AutoPlayLoopNode(90, new PreLeaderBoardWithCompetitorsNode(cf),new PreRaceWithRacemapNode(cf));
|
||||
this.liveRaceLoop = new AutoPlayLoopNode(30, new LiveRaceWithRacemapNode(cf));
|
||||
this.afterLiveRaceLoop = new AutoPlaySequenceNode(30, new RaceEndWithCompetitorsBoatsNode(cf),
|
||||
super(RaceEndWithCompetitorsFlagsNode.class.getName(), cf);
|
||||
this.idleLoop = new AutoPlayLoopNode("IdleLoop", 30, new IdleUpNextNode(cf),
|
||||
new IdleOverallLeaderBoardNode(cf));
|
||||
this.preLiveRaceLoop = new AutoPlayLoopNode("PreLiveRaceLoop", 90, new PreLiveRaceLeaderBoardWithCompetitorsNode(cf),
|
||||
new PreLiveRaceWithRacemapNode(cf));
|
||||
this.liveRaceLoop = new AutoPlayLoopNode("LiveRaceLoop", 30, new LiveRaceWithRacemapNode(cf));
|
||||
this.afterLiveRaceLoop = new AutoPlaySequenceNode("AfterLiveRaceLoop", 30,
|
||||
new RaceEndWithCompetitorsBoatsNode(cf),
|
||||
new RaceEndWithCompetitorsFlagsNode(cf));
|
||||
|
||||
afterLiveRaceLoop.setOnSequenceEnd(new Command() {
|
||||
@@ -32,7 +36,8 @@ public class RootNodeSixtyInch extends RootNodeBase {
|
||||
});
|
||||
}
|
||||
|
||||
protected boolean processStateTransition(RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
protected boolean processStateTransition(RegattaAndRaceIdentifier currentPreLiveRace,
|
||||
RegattaAndRaceIdentifier currentLiveRace, RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
// block transitions, until the afterLiveRaceLoop is finished
|
||||
if (comingFrom == RootNodeState.AFTER_LIVE) {
|
||||
if(afterRaceFinished){
|
||||
@@ -41,6 +46,7 @@ public class RootNodeSixtyInch extends RootNodeBase {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
getClientFactory().getAutoPlayCtx().updateLiveRace(currentPreLiveRace, currentLiveRace);
|
||||
switch (goingTo) {
|
||||
case IDLE:
|
||||
transitionTo(idleLoop);
|
||||
|
||||
+5
-1
@@ -11,6 +11,7 @@ public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
private List<AutoPlayNode> nodes = new ArrayList<>();
|
||||
private int loopTimePerNodeInSeconds;
|
||||
private int currentPos = -1;
|
||||
|
||||
private Timer transitionTimer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -34,19 +35,22 @@ public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
}
|
||||
}
|
||||
|
||||
public AutoPlayLoopNode(int loopTimePerNodeInSeconds, AutoPlayNode... nodes) {
|
||||
public AutoPlayLoopNode(String name, int loopTimePerNodeInSeconds, AutoPlayNode... nodes) {
|
||||
super(name);
|
||||
this.loopTimePerNodeInSeconds = loopTimePerNodeInSeconds;
|
||||
this.nodes.addAll(Arrays.asList(nodes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
log("Start sequence " + getName());
|
||||
currentPos = -1;
|
||||
gotoNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
log("Stop sequence " + getName());
|
||||
super.onStop();
|
||||
for (AutoPlayNode autoPlayNode : nodes) {
|
||||
autoPlayNode.stop();
|
||||
|
||||
+2
@@ -3,7 +3,9 @@ package com.sap.sailing.gwt.autoplay.client.nodes.base;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
public interface AutoPlayNode {
|
||||
String getName();
|
||||
void start(EventBus eventBus);
|
||||
void stop();
|
||||
|
||||
void log(String logMessage);
|
||||
}
|
||||
+26
@@ -1,14 +1,29 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes.base;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.google.web.bindery.event.shared.ResettableEventBus;
|
||||
|
||||
public abstract class AutoPlayNodeBase implements AutoPlayNode {
|
||||
private static final Logger LOG = Logger.getLogger(AutoPlaySequenceNode.class.getName());
|
||||
private ResettableEventBus bus;
|
||||
private boolean isStopped;
|
||||
private String name;
|
||||
|
||||
public AutoPlayNodeBase(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void start(EventBus bus) {
|
||||
log("starting node, wrapping bus");
|
||||
isStopped = false;
|
||||
this.bus = new ResettableEventBus(bus);
|
||||
onStart();
|
||||
@@ -16,6 +31,7 @@ public abstract class AutoPlayNodeBase implements AutoPlayNode {
|
||||
|
||||
@Override
|
||||
public final void stop() {
|
||||
log("stopping node, resetting bus");
|
||||
isStopped = true;
|
||||
onStop();
|
||||
if (bus != null) {
|
||||
@@ -36,4 +52,14 @@ public abstract class AutoPlayNodeBase implements AutoPlayNode {
|
||||
return bus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String logMessage) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(">> AUTOPLAY ");
|
||||
msg.append(getName());
|
||||
msg.append(" >> ");
|
||||
msg.append(logMessage);
|
||||
LOG.info(msg.toString());
|
||||
}
|
||||
|
||||
}
|
||||
+7
-3
@@ -8,11 +8,11 @@ import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
|
||||
public class AutoPlaySequenceNode extends BaseCompositeNode {
|
||||
|
||||
private List<AutoPlayNode> nodes = new ArrayList<>();
|
||||
private int sequenceTimePerNodeInSeconds;
|
||||
private int currentPos = -1;
|
||||
private Command onLoopEnd;
|
||||
|
||||
private Timer transitionTimer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -34,13 +34,15 @@ public class AutoPlaySequenceNode extends BaseCompositeNode {
|
||||
|
||||
@Override
|
||||
protected void transitionTo(AutoPlayNode nextNode) {
|
||||
log("Sequence transition to " + nextNode);
|
||||
super.transitionTo(nextNode);
|
||||
if (!isStopped()) {
|
||||
transitionTimer.schedule(sequenceTimePerNodeInSeconds * 1000);
|
||||
transitionTimer.schedule(sequenceTimePerNodeInSeconds * 2000);
|
||||
}
|
||||
}
|
||||
|
||||
public AutoPlaySequenceNode(int sequenceTimePerNodeInSeconds, AutoPlayNode... nodes) {
|
||||
public AutoPlaySequenceNode(String name, int sequenceTimePerNodeInSeconds, AutoPlayNode... nodes) {
|
||||
super(name);
|
||||
this.sequenceTimePerNodeInSeconds = sequenceTimePerNodeInSeconds;
|
||||
this.nodes.addAll(Arrays.asList(nodes));
|
||||
}
|
||||
@@ -51,12 +53,14 @@ public class AutoPlaySequenceNode extends BaseCompositeNode {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
log("Start sequence");
|
||||
currentPos = -1;
|
||||
gotoNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
log("Stop sequence ");
|
||||
super.onStop();
|
||||
for (AutoPlayNode autoPlayNode : nodes) {
|
||||
autoPlayNode.stop();
|
||||
|
||||
+9
@@ -3,22 +3,31 @@ package com.sap.sailing.gwt.autoplay.client.nodes.base;
|
||||
public abstract class BaseCompositeNode
|
||||
extends AutoPlayNodeBase {
|
||||
|
||||
public BaseCompositeNode(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private AutoPlayNode currentNode;
|
||||
|
||||
|
||||
public AutoPlayNode getCurrentNode() {
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
protected void transitionTo(AutoPlayNode nextNode) {
|
||||
if (nextNode == currentNode) {
|
||||
log("Same node, not transitioning to " + nextNode);
|
||||
return;
|
||||
}
|
||||
if (isStopped()) {
|
||||
log("This node is stopped, not transitioning ");
|
||||
return;
|
||||
}
|
||||
if (currentNode != null) {
|
||||
log("Stopping current node " + currentNode);
|
||||
currentNode.stop();
|
||||
}
|
||||
log("Transitioning to " + nextNode);
|
||||
currentNode = nextNode;
|
||||
nextNode.start(getBus());
|
||||
}
|
||||
|
||||
+6
@@ -6,10 +6,15 @@ import com.google.gwt.place.shared.PlaceChangeEvent;
|
||||
public abstract class FiresPlaceNode
|
||||
extends AutoPlayNodeBase {
|
||||
|
||||
public FiresPlaceNode(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private Place placeToGo;
|
||||
|
||||
|
||||
public void onStart() {
|
||||
log("Start place node");
|
||||
firePlaceChangeAndStartTimer();
|
||||
}
|
||||
|
||||
@@ -23,6 +28,7 @@ public abstract class FiresPlaceNode
|
||||
|
||||
protected void firePlaceChangeAndStartTimer() {
|
||||
if (placeToGo != null) {
|
||||
log("Fire place change to " + placeToGo);
|
||||
getBus().fireEvent(new PlaceChangeEvent(placeToGo));
|
||||
}
|
||||
}
|
||||
|
||||
+39
-31
@@ -2,7 +2,6 @@ package com.sap.sailing.gwt.autoplay.client.nodes.base;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
@@ -17,20 +16,21 @@ public abstract class RootNodeBase extends BaseCompositeNode {
|
||||
protected static final long PRE_RACE_DELAY = 180000;
|
||||
protected static final long LIVE_SWITCH_DELAY = 1000;
|
||||
private int UPDATE_STATE_TIMER = 5000;
|
||||
|
||||
private final AutoPlayClientFactory cf;
|
||||
private String leaderBoardName;
|
||||
private int errorCount = 0;;
|
||||
private RootNodeState currentState;
|
||||
private RegattaAndRaceIdentifier currentPreLifeRace;
|
||||
private RegattaAndRaceIdentifier currentLifeRace;
|
||||
private RegattaAndRaceIdentifier currentPreLiveRace;
|
||||
private RegattaAndRaceIdentifier currentLiveRace;
|
||||
private Timer checkTimer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
doCheck();
|
||||
}
|
||||
};
|
||||
protected RootNodeBase(AutoPlayClientFactory cf) {
|
||||
|
||||
protected RootNodeBase(String name, AutoPlayClientFactory cf) {
|
||||
super(name);
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
@@ -76,47 +76,53 @@ public abstract class RootNodeBase extends BaseCompositeNode {
|
||||
|
||||
private void _doCheck() {
|
||||
this.leaderBoardName = cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName();
|
||||
AutoplayHelper.getLifeRace(cf.getSailingService(), cf.getErrorReporter(), cf.getAutoPlayCtx().getEvent(),
|
||||
AutoplayHelper.getLiveRace(cf.getSailingService(), cf.getErrorReporter(), cf.getAutoPlayCtx().getEvent(),
|
||||
leaderBoardName, cf.getDispatch(), new AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<Long, RegattaAndRaceIdentifier> result) {
|
||||
errorCount = 0;
|
||||
// we have no race, or we have one, and had a different one in the past
|
||||
if (result == null || (currentLifeRace != null && !result.getB().equals(currentLifeRace))) {
|
||||
cf.getAutoPlayCtx().setCurrentLifeRace(null);
|
||||
boolean comingFromLiferace = currentLifeRace != null || currentPreLifeRace != null
|
||||
|| (result != null && !result.getB().equals(currentLifeRace));
|
||||
setCurrentState(comingFromLiferace ? RootNodeState.AFTER_LIVE : RootNodeState.IDLE,
|
||||
if (result == null || (currentLiveRace != null && !result.getB().equals(currentLiveRace))) {
|
||||
boolean comingFromLiveRace = currentLiveRace != null || currentPreLiveRace != null
|
||||
|| (result != null && !result.getB().equals(currentLiveRace));
|
||||
setCurrentState(comingFromLiveRace ? RootNodeState.AFTER_LIVE : RootNodeState.IDLE,
|
||||
currentState);
|
||||
currentLifeRace = null;
|
||||
currentPreLifeRace = null;
|
||||
currentLiveRace = null;
|
||||
currentPreLiveRace = null;
|
||||
} else {
|
||||
cf.getAutoPlayCtx().setCurrentLifeRace(result.getB());
|
||||
final Long timeToRaceStartInMs = result.getA();
|
||||
final RegattaAndRaceIdentifier loadedLiveRace = result.getB();
|
||||
if (loadedLiveRace == null || timeToRaceStartInMs > PRE_RACE_DELAY) {
|
||||
boolean comingFromLiferace = currentLifeRace != null || currentPreLifeRace != null;
|
||||
GWT.log("FallbackToIdleLoopEvent: isComingFromLiferace: " + comingFromLiferace);
|
||||
setCurrentState(comingFromLiferace ? RootNodeState.AFTER_LIVE : RootNodeState.IDLE,
|
||||
boolean comingFromLiveRace = currentLiveRace != null || currentPreLiveRace != null;
|
||||
if (loadedLiveRace == null) {
|
||||
log("No live race, isComingFromLiveRace: " + comingFromLiveRace);
|
||||
} else {
|
||||
log("Live race is too far away, isComingFromLiveRace: " + comingFromLiveRace);
|
||||
}
|
||||
setCurrentState(comingFromLiveRace ? RootNodeState.AFTER_LIVE : RootNodeState.IDLE,
|
||||
currentState);
|
||||
currentLifeRace = null;
|
||||
currentPreLifeRace = null;
|
||||
currentLiveRace = null;
|
||||
currentPreLiveRace = null;
|
||||
} else if (/* is pre liverace */ timeToRaceStartInMs < PRE_RACE_DELAY
|
||||
&& timeToRaceStartInMs > LIVE_SWITCH_DELAY) {
|
||||
if (/* is new pre live race */!loadedLiveRace.equals(currentPreLifeRace)) {
|
||||
if (/* is new pre live race */!loadedLiveRace.equals(currentPreLiveRace)) {
|
||||
log("New pre live race: " + loadedLiveRace.getRaceName());
|
||||
boolean veto = setCurrentState(RootNodeState.PRE_RACE, currentState);
|
||||
if (!veto) {
|
||||
currentPreLifeRace = loadedLiveRace;
|
||||
currentLifeRace = null;
|
||||
GWT.log("UpcomingLiferaceDetectedEvent: " + loadedLiveRace.toString());
|
||||
currentPreLiveRace = loadedLiveRace;
|
||||
currentLiveRace = null;
|
||||
log("Switched to pre live race: " + loadedLiveRace.getRaceName());
|
||||
} else {
|
||||
log("Veto, not switching to pre live race: " + loadedLiveRace.getRaceName());
|
||||
}
|
||||
}
|
||||
} else /* is live race */ {
|
||||
currentPreLifeRace = null;
|
||||
if (/* is new live race */!loadedLiveRace.equals(currentLifeRace)) {
|
||||
currentPreLiveRace = null;
|
||||
if (/* is new live race */!loadedLiveRace.equals(currentLiveRace)) {
|
||||
log("New live race: " + loadedLiveRace.getRaceName());
|
||||
boolean veto = setCurrentState(RootNodeState.LIVE, currentState);
|
||||
if (!veto) {
|
||||
currentLifeRace = loadedLiveRace;
|
||||
currentLiveRace = loadedLiveRace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,17 +141,18 @@ public abstract class RootNodeBase extends BaseCompositeNode {
|
||||
|
||||
private final boolean setCurrentState(RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
if (goingTo != comingFrom) {
|
||||
boolean veto = processStateTransition(goingTo, comingFrom);
|
||||
log("RootNodeBase transition " + comingFrom + " -> " + goingTo);
|
||||
boolean veto = processStateTransition(currentPreLiveRace, currentLiveRace, goingTo, comingFrom);
|
||||
if (veto) {
|
||||
GWT.log("Vetoed switching to state " + goingTo + " coming from " + comingFrom);
|
||||
log("Vetoed switching to state " + goingTo + " coming from " + comingFrom);
|
||||
} else {
|
||||
// only update the state if it was not vetoed, to ensure that a futurs change comingFrom is clean
|
||||
GWT.log("Switching to state " + goingTo + " coming from " + comingFrom);
|
||||
log("Switching to state " + goingTo + " coming from " + comingFrom);
|
||||
this.currentState = goingTo;
|
||||
}
|
||||
return veto;
|
||||
} else {
|
||||
GWT.log("Transition to same autoplay state, skipping");
|
||||
log("Transition to same autoplay state, skipping");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -158,7 +165,8 @@ public abstract class RootNodeBase extends BaseCompositeNode {
|
||||
cf.getPlaceController().goTo(cf.getDefaultPlace());
|
||||
}
|
||||
|
||||
protected abstract boolean processStateTransition(RootNodeState goingTo, RootNodeState comingFrom);
|
||||
protected abstract boolean processStateTransition(RegattaAndRaceIdentifier currentLiveRace,
|
||||
RegattaAndRaceIdentifier currentPreLiveRace, RootNodeState goingTo, RootNodeState comingFrom);
|
||||
|
||||
protected abstract void processFailure(FailureEvent event);
|
||||
}
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class LiveRaceWithRacemapAndLeaderBoardPresenterImpl extends AutoPlayPres
|
||||
SailingServiceAsync sailingService = getClientFactory().getSailingService();
|
||||
ErrorReporter errorReporter = getClientFactory().getErrorReporter();
|
||||
|
||||
RegattaAndRaceIdentifier lifeRace = getSlideCtx().getLifeRace();
|
||||
RegattaAndRaceIdentifier lifeRace = getSlideCtx().getLiveRace();
|
||||
ArrayList<String> racesToShow = null;
|
||||
if (lifeRace != null) {
|
||||
racesToShow = new ArrayList<>();
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class PreLeaderBoardWithImagePresenterImpl
|
||||
ErrorReporter errorReporter = getClientFactory().getErrorReporter();
|
||||
view.startingWith(this, panel);
|
||||
|
||||
RegattaAndRaceIdentifier lifeRace = getSlideCtx().getLifeRace();
|
||||
RegattaAndRaceIdentifier lifeRace = getSlideCtx().getLiveRace();
|
||||
ArrayList<String> racesToShow = null;
|
||||
if (lifeRace != null) {
|
||||
racesToShow = new ArrayList<>();
|
||||
|
||||
+3
-3
@@ -43,7 +43,7 @@ public class PreRaceRacemapPresenterImpl extends AutoPlayPresenterConfigured<Pre
|
||||
view.showErrorNoLive(this, panel, getPlace().getError());
|
||||
return;
|
||||
}
|
||||
view.nextRace(getSlideCtx().getLifeRace());
|
||||
view.nextRace(getSlideCtx().getLiveRace());
|
||||
reloadStatistics();
|
||||
reloadStatistics = new Timer() {
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class PreRaceRacemapPresenterImpl extends AutoPlayPresenterConfigured<Pre
|
||||
|
||||
}
|
||||
String url = getRaceViewerURL(getSlideCtx().getContextDefinition().getLeaderboardName(), null,
|
||||
getSlideCtx().getLifeRace());
|
||||
getSlideCtx().getLiveRace());
|
||||
view.updateStatistic(lastStatisticResult, url, windSpeed,
|
||||
windDegree);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class PreRaceRacemapPresenterImpl extends AutoPlayPresenterConfigured<Pre
|
||||
}
|
||||
|
||||
private void reloadStatistics() {
|
||||
RegattaAndRaceIdentifier upcomingRace = getSlideCtx().getLifeRace();
|
||||
RegattaAndRaceIdentifier upcomingRace = getSlideCtx().getLiveRace();
|
||||
getClientFactory().getDispatch().execute(
|
||||
new GetSixtyInchStatisticAction(upcomingRace.getRaceName(), upcomingRace.getRegattaName()),
|
||||
new AsyncCallback<GetSixtyInchStatisticDTO>() {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class AutoplayHelper {
|
||||
private static Timer raceboardTimer = new Timer(PlayModes.Live, /* delayBetweenAutoAdvancesInMilliseconds */1000l);
|
||||
public static final AsyncActionsExecutor asyncActionsExecutor = new AsyncActionsExecutor();
|
||||
|
||||
public static void getLifeRace(SailingServiceAsync sailingService,
|
||||
public static void getLiveRace(SailingServiceAsync sailingService,
|
||||
ErrorReporter errorReporter, EventDTO event, String leaderBoardName, SailingDispatchSystem dispatch,
|
||||
AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>> callback) {
|
||||
raceboardTimer.reset();
|
||||
|
||||
Reference in new issue
Block a user