View Javadoc

1   package cz.cuni.amis.pogamut.udk.communication.translator.bot.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.udk.communication.messages.gbinfomessages.Mover;
8   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.MoverListEnd;
9   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.MoverListStart;
10  import cz.cuni.amis.pogamut.udk.communication.translator.TranslatorContext;
11  import cz.cuni.amis.pogamut.udk.communication.translator.bot.support.BotListState;
12  import cz.cuni.amis.pogamut.udk.communication.translator.shared.events.MoverListObtained;
13  
14  
15  /**
16   * Takes care of the mover list. It stores them inside a List object and when END message comes it sends
17   * them to the world view via MoverListObtained event.
18   * @author Knight
19   */
20  @FSMState(map={
21  				@FSMTransition(
22  					state=HandshakeControllerState.class,
23  					symbol={MoverListEnd.class},
24  					transition={})
25  				}
26  )
27  public class MoverListState extends BotListState<Mover, TranslatorContext>{
28  
29  	public MoverListState() {
30  		super(MoverListStart.class, Mover.class, MoverListEnd.class);
31  	}
32  
33  	@Override
34  	public void stateEntering(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> fromState, InfoMessage symbol) {
35  		super.restart(context);
36  		super.stateEntering(context, fromState, symbol);
37  	}
38  
39  	@Override
40  	public void stateLeaving(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
41  		super.stateLeaving(context, toState, symbol);
42  		context.getEventQueue().pushEvent(new MoverListObtained(getList()));
43  		newList();
44  	}
45  
46  	@Override
47  	public void stateSymbol(TranslatorContext context, InfoMessage symbol) {
48  		super.stateSymbol(context, symbol);
49  		context.getEventQueue().pushEvent((Mover)symbol);
50  	}
51  
52  }