View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2    		
3    		// --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4   			import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5   		// --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6   		
7   		
8   		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9   				
10  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11  		
12  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the GameBots2004 message UPD.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		"Synchronous" message. Arrives outside sync. batch. The frequency of this message is configured through locUpdateMultiplier variable in GameBots2004.ini file. It gets exported N times faster than regular sync. batch where N equals locUpdateMultiplier. Holds information about Location, Velocity and Rotation of the bot and should help us to create more robust navigation.
25  	
26           */
27   	public abstract class LocationUpdate   
28    				extends 
29    				InfoMessage
30    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31    						
32  	    {
33   	
34      	/** Example how the message looks like - used during parser tests. */
35      	public static final String PROTOTYPE =
36      		"UPD {Id unreal_id}  {Loc 0,0,0}  {Vel 0,0,0}  {Rot 0,0,0} ";
37      
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public LocationUpdate()
44  		{
45  		}
46  	
47  				// abstract message, it does not have any more constructors				
48  			
49  	   		
50  			protected long SimTime;
51  				
52  			/**
53  			 * Simulation time in MILLI SECONDS !!!
54  			 */	
55  			@Override
56  			public long getSimTime() {
57  				return SimTime;
58  			}
59  						
60  			/**
61  			 * Used by Yylex to slip correct time of the object or programmatically.
62  			 */
63  			protected void setSimTime(long SimTime) {
64  				this.SimTime = SimTime;
65  			}
66  	   	
67   		/**
68           * Unique Id of this update message instance. 
69           */
70          public abstract UnrealId getId()
71   	;
72  		    			
73   		/**
74           * 
75  			An absolute location of the bot.
76  		 
77           */
78          public abstract Location getLoc()
79   	;
80  		    			
81   		/**
82           * 
83  			Absolute velocity of the bot as a vector of movement per one
84  			game second.
85  		 
86           */
87          public abstract Velocity getVel()
88   	;
89  		    			
90   		/**
91           * 
92  			Which direction the bot is facing in absolute terms.
93  		 
94           */
95          public abstract Rotation getRot()
96   	;
97  		    			
98      	
99      	public static class LocationUpdateUpdate
100      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
101 			private LocationUpdate object;
102 			private long time;
103 			private ITeamId teamId;
104 			
105 			public LocationUpdateUpdate
106     (LocationUpdate source, long eventTime, ITeamId teamId) {
107 				this.object = source;
108 				this.time = eventTime;
109 				this.teamId = teamId;
110 			}
111 			
112 			/**
113 			 * Simulation time in MILLI SECONDS !!!
114 			 */ 
115 			@Override
116 			public long getSimTime() {
117 				return time;
118 			}
119 	
120 			@Override
121 			public IWorldObject getObject() {
122 				return object;
123 			}
124 	
125 			@Override
126 			public WorldObjectId getId() {
127 				return object.getId();
128 			}
129 	
130 			@Override
131 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
132 				return new LocationUpdateLocalImpl.LocationUpdateLocalUpdate
133     ((LocationUpdateLocal)object.getLocal(), time);
134 			}
135 	
136 			@Override
137 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
138 				return new LocationUpdateSharedImpl.LocationUpdateSharedUpdate
139     ((LocationUpdateShared)object.getShared(), time, teamId);
140 			}
141 	
142 			@Override
143 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
144 				return new LocationUpdateStaticImpl.LocationUpdateStaticUpdate
145     ((LocationUpdateStatic)object.getStatic(), time);
146 			}
147 			
148 		}
149     
150  		
151  	    public String toString() {
152             return
153             	super.toString() + "[" +
154             	
155 		              			"Id = " + String.valueOf(getId()
156  	) + " | " + 
157 		              		
158 		              			"Loc = " + String.valueOf(getLoc()
159  	) + " | " + 
160 		              		
161 		              			"Vel = " + String.valueOf(getVel()
162  	) + " | " + 
163 		              		
164 		              			"Rot = " + String.valueOf(getRot()
165  	) + " | " + 
166 		              		
167 				"]";           		
168         }
169  	
170  		
171  		public String toHtmlString() {
172  			return super.toString() + "[<br/>" +
173             	
174 		              			"<b>Id</b> = " + String.valueOf(getId()
175  	) + " <br/> " + 
176 		              		
177 		              			"<b>Loc</b> = " + String.valueOf(getLoc()
178  	) + " <br/> " + 
179 		              		
180 		              			"<b>Vel</b> = " + String.valueOf(getVel()
181  	) + " <br/> " + 
182 		              		
183 		              			"<b>Rot</b> = " + String.valueOf(getRot()
184  	) + " <br/> " + 
185 		              		
186 				"<br/>]";     
187 		}
188  	
189  	    public String toJsonLiteral() {
190             return "locationupdate( "
191             		+
192 									(getId()
193  	 == null ? "null" :
194 										"\"" + getId()
195  	.getStringId() + "\"" 
196 									)
197 								+ ", " + 
198 								    (getLoc()
199  	 == null ? "null" :
200 										"[" + getLoc()
201  	.getX() + ", " + getLoc()
202  	.getY() + ", " + getLoc()
203  	.getZ() + "]" 
204 									)
205 								+ ", " + 
206 								    (getVel()
207  	 == null ? "null" :
208 										"[" + getVel()
209  	.getX() + ", " + getVel()
210  	.getY() + ", " + getVel()
211  	.getZ() + "]" 
212 									)
213 								+ ", " + 
214 									(getRot()
215  	 == null ? "null" :
216 										"[" + getRot()
217  	.getPitch() + ", " + getRot()
218  	.getYaw() + ", " + getRot()
219  	.getRoll() + "]" 
220 									)								    
221 								
222                    + ")";
223         }
224  	
225  		
226  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
227         	
228 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
229 		
230 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
231 	        
232 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
233  	
234 		}
235