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=static]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=static]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              				Implementation of the static part of the GameBots2004 message ALIVE.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Alive message are for confirmation, that
25  		the connection is still working. They are sent periodically with
26  		usual period of one second (this can change depending on the
27  		configuration of ControlServer)
28  	
29           */
30   	public class AliveMessageStaticImpl 
31    						extends
32    						AliveMessageStatic
33  	    {
34   	
35      	
36      	
37      	/**
38      	 * Parameter-less contructor for the message.
39      	 */
40  		public AliveMessageStaticImpl()
41  		{
42  		}
43  	
44      	/**
45  		 * Cloning constructor from the full message.
46  		 *
47  		 * @param original
48  		 */
49  		public AliveMessageStaticImpl(AliveMessage original) {		
50  			
51  			this.SimTime = original.getSimTime();			
52  		}
53  		
54  		/**
55  		 * Cloning constructor from the full message.
56  		 *
57  		 * @param original
58  		 */
59  		public AliveMessageStaticImpl(AliveMessageStaticImpl original) {		
60  			
61  			this.SimTime = original.getSimTime();
62  		}
63  		
64  			/**
65  			 * Cloning constructor from the message part.
66  			 *
67  			 * @param original
68  			 */
69  			public AliveMessageStaticImpl(AliveMessageStatic original) {
70  				
71  			}
72  		
73  						
74  						public UnrealId getId() {						
75  							return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
76  						}
77  					
78     				
79     				@Override
80     				public void setSimTime(long SimTime) {
81  					super.setSimTime(SimTime);
82  				}
83     			
84  	    				@Override
85  	    				public 
86  	    				AliveMessageStaticImpl clone() {
87  	    					return new 
88  	    					AliveMessageStaticImpl(this);
89  	    				}
90  	    				
91  	    				
92      	
93      	
94      	public static class AliveMessageStaticUpdate
95       implements IStaticWorldObjectUpdatedEvent
96  		{
97  			
98  			private AliveMessageStatic data;
99  			private long time;
100 			
101 			public AliveMessageStaticUpdate
102     (AliveMessageStatic source, long time)
103 			{
104 				this.data = source;
105 				this.time = time;
106 			}
107 			
108 			/**
109 			 * Simulation time in MILLI SECONDS !!!
110 			 */
111 			@Override
112 			public long getSimTime() {
113 				return time;
114 			}
115 	
116 			@Override
117 			public WorldObjectId getId() {
118 				return data.getId();
119 			}
120 			
121 			@Override
122 			public IWorldObjectUpdateResult<IStaticWorldObject> update(
123 					IStaticWorldObject object) {
124 				if ( object == null)
125 				{
126 					data = new AliveMessageStaticImpl(data);
127 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
128 				}
129 				//since static objects can't be updated, we'll just check that the object stays the same
130 				if ( object instanceof AliveMessageStaticImpl)
131 				{
132 					AliveMessageStaticImpl orig = (AliveMessageStaticImpl)object;
133 					//since these errors usually mean error in gamebots, we will just print an error message
134 					if ( data.isDifferentFrom(orig) )
135 					{
136 						//data.isDifferentFrom(orig);
137 						//throw new PogamutException("Trying to modify static object " + this.data.getId().toString() , this);
138 						System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : AliveMessageStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
139 					}
140 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
141 				}				
142 				throw new PogamutException("Unexpected object type for update, AliveMessageStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
143 			}
144 		}
145 	
146     
147  		
148  		@Override
149  		public boolean isDifferentFrom(IStaticWorldObject other)
150  		{
151  			if (other == null) //early fail
152  			{
153  				return true;
154  			}
155  			else if (other == this) //early out
156  			{
157  				return false;
158  			}
159  			else
160  			{
161  				AliveMessageStatic obj = (AliveMessageStatic) other;
162 
163  				
164  			}
165  			return false;
166  		}
167  	 
168  		
169  	    public String toString() {
170             return
171             	super.toString() + "[" +
172             	
173 				"]";           		
174         }
175  	
176  		
177  		public String toHtmlString() {
178  			return super.toString() + "[<br/>" +
179             	
180 				"<br/>]";     
181 		}
182  	
183  		
184  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
185         	
186 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
187 		
188 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---
189 	        
190 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---        	            	
191  	
192 		}
193