View Javadoc

1   /**
2    * Emohawk Bot, an implementation of the environment interface standard that 
3    * facilitates the connection between GOAL and Emohawk. 
4    * 
5    * Copyright (C) 2012 Emohawk Bot authors.
6    * 
7    * This program is free software: you can redistribute it and/or modify it under
8    * the terms of the GNU General Public License as published by the Free Software
9    * Foundation, either version 3 of the License, or (at your option) any later
10   * version.
11   * 
12   * This program is distributed in the hope that it will be useful, but WITHOUT
13   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15   * details.
16   * 
17   * You should have received a copy of the GNU General Public License along with
18   * this program. If not, see <http://www.gnu.org/licenses/>.
19   */
20  
21  package nl.tudelft.goal.emohawk.translators;
22  
23  import nl.tudelft.goal.EIS2Java.exception.TranslationException;
24  import nl.tudelft.goal.EIS2Java.translation.Java2Parameter;
25  import nl.tudelft.goal.EIS2Java.translation.Translator;
26  import nl.tudelft.goal.unreal.translators.LocationTranslator;
27  import nl.tudelft.goal.unreal.translators.RotationTranslator;
28  import cz.cuni.amis.pogamut.emohawk.agent.module.sensomotoric.EmoticonType;
29  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
30  import eis.iilang.Function;
31  import eis.iilang.Identifier;
32  import eis.iilang.Parameter;
33  
34  public class AgentInfoTranslator implements Java2Parameter<AgentInfo> {
35  
36  	@Override
37  	public Parameter[] translate(AgentInfo o) throws TranslationException {
38  		EmoticonType emoteLeft = EmoticonType.get(o.getSelf().getEmotLeft());
39  		EmoticonType emoteCenter = EmoticonType.get(o.getSelf().getEmotCenter());
40  		EmoticonType emoteRight = EmoticonType.get(o.getSelf().getEmotRight());
41  		
42  		return new Parameter[] {
43  				new Identifier(o.getSelf().getId().getStringId()), 
44  				new Identifier(o.getName()),
45  				Translator.getInstance().translate2Parameter(o.getLocation())[0],
46  				Translator.getInstance().translate2Parameter(o.getRotation())[0],
47  				Translator.getInstance().translate2Parameter(emoteLeft)[0], 
48  				Translator.getInstance().translate2Parameter(emoteCenter)[0], 
49  				Translator.getInstance().translate2Parameter(emoteRight)[0]};
50  	}
51  
52  	@Override
53  	public Class<? extends AgentInfo> translatesFrom() {
54  		return AgentInfo.class;
55  	}
56  
57  }