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=event]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15      
16   		/**
17           *  
18           			Definition of the event 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 class LocationUpdate 
28    				extends InfoMessage
29      			implements IWorldEvent, IWorldChangeEvent
30      			
31  	    {
32   	
33      	/** Example how the message looks like - used during parser tests. */
34      	public static final String PROTOTYPE =
35      		"UPD {Loc 0,0,0}  {Vel 0,0,0}  {Rot 0,0,0} ";
36      
37      	
38      	
39      	/**
40      	 * Parameter-less contructor for the message.
41      	 */
42  		public LocationUpdate()
43  		{
44  		}
45  	
46      	
47      	
48      	
49      	/**
50  		 * Creates new instance of the message LocationUpdate.
51  		 * 
52  		"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.
53  	
54  		 * Corresponding GameBots message
55  		 *   
56  		 *   is
57  		 *   UPD.
58  		 * 
59   	  	 * 
60  		 *   
61  		 *     @param Loc 
62  			An absolute location of the bot.
63  		
64  		 *   
65  		 * 
66  		 *   
67  		 *     @param Vel 
68  			Absolute velocity of the bot as a vector of movement per one
69  			game second.
70  		
71  		 *   
72  		 * 
73  		 *   
74  		 *     @param Rot 
75  			Which direction the bot is facing in absolute terms.
76  		
77  		 *   
78  		 * 
79  		 */
80  		public LocationUpdate(
81  			Location Loc,  Velocity Vel,  Rotation Rot
82  		) {
83  			
84  					this.Loc = Loc;
85  				
86  					this.Vel = Vel;
87  				
88  					this.Rot = Rot;
89  				
90  		}
91      
92      	/**
93  		 * Cloning constructor from the full message.
94  		 *
95  		 * @param original
96  		 */
97  		public LocationUpdate(LocationUpdate original) {		
98  			
99  					this.Loc = original.getLoc()
100  	;
101 				
102 					this.Vel = original.getVel()
103  	;
104 				
105 					this.Rot = original.getRot()
106  	;
107 				
108 			this.SimTime = original.getSimTime();			
109 		}
110 		
111 	   		
112 			protected long SimTime;
113 				
114 			/**
115 			 * Simulation time in MILLI SECONDS !!!
116 			 */	
117 			@Override
118 			public long getSimTime() {
119 				return SimTime;
120 			}
121 						
122 			/**
123 			 * Used by Yylex to slip correct time of the object or programmatically.
124 			 */
125 			protected void setSimTime(long SimTime) {
126 				this.SimTime = SimTime;
127 			}
128 	   	
129     	
130 	    /**
131          * 
132 			An absolute location of the bot.
133 		 
134          */
135         protected
136          Location Loc =
137        	null;
138 	
139  		/**
140          * 
141 			An absolute location of the bot.
142 		 
143          */
144         public  Location getLoc()
145  	 {
146     					return Loc;
147     				}
148     			
149     	
150 	    /**
151          * 
152 			Absolute velocity of the bot as a vector of movement per one
153 			game second.
154 		 
155          */
156         protected
157          Velocity Vel =
158        	null;
159 	
160  		/**
161          * 
162 			Absolute velocity of the bot as a vector of movement per one
163 			game second.
164 		 
165          */
166         public  Velocity getVel()
167  	 {
168     					return Vel;
169     				}
170     			
171     	
172 	    /**
173          * 
174 			Which direction the bot is facing in absolute terms.
175 		 
176          */
177         protected
178          Rotation Rot =
179        	null;
180 	
181  		/**
182          * 
183 			Which direction the bot is facing in absolute terms.
184 		 
185          */
186         public  Rotation getRot()
187  	 {
188     					return Rot;
189     				}
190     			
191  		
192  	    public String toString() {
193             return
194             	super.toString() + "[" +
195             	
196 		              			"Loc = " + String.valueOf(getLoc()
197  	) + " | " + 
198 		              		
199 		              			"Vel = " + String.valueOf(getVel()
200  	) + " | " + 
201 		              		
202 		              			"Rot = " + String.valueOf(getRot()
203  	) + " | " + 
204 		              		
205 				"]";           		
206         }
207  	
208  		
209  		public String toHtmlString() {
210  			return super.toString() + "[<br/>" +
211             	
212 		              			"<b>Loc</b> = " + String.valueOf(getLoc()
213  	) + " <br/> " + 
214 		              		
215 		              			"<b>Vel</b> = " + String.valueOf(getVel()
216  	) + " <br/> " + 
217 		              		
218 		              			"<b>Rot</b> = " + String.valueOf(getRot()
219  	) + " <br/> " + 
220 		              		
221 				"<br/>]";     
222 		}
223  	
224  	    public String toJsonLiteral() {
225             return "locationupdate( "
226             		+
227 								    (getLoc()
228  	 == null ? "null" :
229 										"[" + getLoc()
230  	.getX() + ", " + getLoc()
231  	.getY() + ", " + getLoc()
232  	.getZ() + "]" 
233 									)
234 								+ ", " + 
235 								    (getVel()
236  	 == null ? "null" :
237 										"[" + getVel()
238  	.getX() + ", " + getVel()
239  	.getY() + ", " + getVel()
240  	.getZ() + "]" 
241 									)
242 								+ ", " + 
243 									(getRot()
244  	 == null ? "null" :
245 										"[" + getRot()
246  	.getPitch() + ", " + getRot()
247  	.getYaw() + ", " + getRot()
248  	.getRoll() + "]" 
249 									)								    
250 								
251                    + ")";
252         }
253  	
254  		
255  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
256         	
257 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
258 		
259 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
260 	        
261 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
262  	
263 		}
264