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.Vehicle;
8   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.VehicleListEnd;
9   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.VehicleListStart;
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.VehicleListObtained;
13  
14  /**
15   * Takes care of the vehicle list. It stores them inside a List object and when END message comes it sends
16   * them to the world view via VehicleListObtained event.
17   * <p><p>
18   * Last state of the handshake - we switch from this state to the ConfigureMessageExpectedState. 
19   * 
20   * @author Radek 'Black_Hand' Pibil
21   */
22  @FSMState(map={@FSMTransition(
23  					state=HandshakeControllerState.class, 
24  					symbol={VehicleListEnd.class},
25  					transition={})}
26  )
27  public class VehicleListState extends BotListState<Vehicle, TranslatorContext> {
28  
29  	public VehicleListState() {
30  		super(VehicleListStart.class, Vehicle.class, VehicleListEnd.class);
31  	}
32  	
33  	@Override
34  	public void stateLeaving(TranslatorContext context,
35  			IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
36  		super.stateLeaving(context, toState, symbol);
37  		context.getEventQueue().pushEvent(new VehicleListObtained(getList()));
38  		newList();
39  	}
40  	
41  	@Override
42  	public void stateSymbol(TranslatorContext context, InfoMessage symbol) {
43  		super.stateSymbol(context, symbol);
44  		context.getEventQueue().pushEvent((Vehicle)symbol);
45  	}	
46  	
47  }