1 package cz.cuni.amis.pogamut.ut2004.communication.translator.server.state;
2
3 import cz.cuni.amis.fsm.FSMState;
4 import cz.cuni.amis.fsm.FSMTransition;
5 import cz.cuni.amis.fsm.IFSMState;
6 import cz.cuni.amis.pogamut.base.communication.messages.InfoMessage;
7 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldChangeEvent;
8 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PathList;
9 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PathListEnd;
10 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PathListStart;
11 import cz.cuni.amis.pogamut.ut2004.communication.translator.TranslatorContext;
12 import cz.cuni.amis.pogamut.ut2004.communication.translator.server.support.ServerListState;
13 import cz.cuni.amis.pogamut.ut2004.communication.translator.shared.events.Path;
14
15
16
17
18
19
20 @FSMState(map = {
21 @FSMTransition(
22 state = ServerRunningState.class,
23 symbol = {PathListEnd.class },
24 transition = {}
25 )
26 }
27 )
28 public class PathAcceptState extends ServerListState<PathList, TranslatorContext> {
29
30 private String pathId = null;
31
32 public PathAcceptState() {
33 super(PathListStart.class, PathList.class, PathListEnd.class);
34 }
35
36 @Override
37 public void stateEntering(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> fromState, InfoMessage symbol) {
38 super.stateEntering(context, fromState, symbol);
39 pathId = ((PathListStart)symbol).getMessageId();
40 }
41
42 @Override
43 public void stateLeaving(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
44 super.stateLeaving(context, toState, symbol);
45 long simTime =
46 (symbol instanceof IWorldChangeEvent ? ((IWorldChangeEvent)symbol).getSimTime() : 0);
47 context.getEventQueue().pushEvent(new Path(pathId, getList(), simTime));
48 getList().clear();
49 }
50 }