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 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 abstract class AliveMessage   
31    				extends 
32    				InfoMessage
33    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
34    						
35  	    {
36   	
37      	/** Example how the message looks like - used during parser tests. */
38      	public static final String PROTOTYPE =
39      		"ALIVE {Time 0} ";
40      
41      	
42      	
43      	/**
44      	 * Parameter-less contructor for the message.
45      	 */
46  		public AliveMessage()
47  		{
48  		}
49  	
50  				// abstract message, it does not have any more constructors				
51  			
52  						
53  						public static final UnrealId AliveMessageId = UnrealId.get("AliveMessageId");
54  					
55  						
56  						public UnrealId getId() {						
57  							return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
58  						}
59  					
60  	   		
61  			protected long SimTime;
62  				
63  			/**
64  			 * Simulation time in MILLI SECONDS !!!
65  			 */	
66  			@Override
67  			public long getSimTime() {
68  				return SimTime;
69  			}
70  						
71  			/**
72  			 * Used by Yylex to slip correct time of the object or programmatically.
73  			 */
74  			protected void setSimTime(long SimTime) {
75  				this.SimTime = SimTime;
76  			}
77  	   	
78   		/**
79           * 
80  			Game time when this message was send.
81  		 
82           */
83          public abstract double getTime()
84   	;
85  		    			
86      	
87      	public static class AliveMessageUpdate
88       extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
89  			private AliveMessage object;
90  			private long time;
91  			private ITeamId teamId;
92  			
93  			public AliveMessageUpdate
94      (AliveMessage source, long eventTime, ITeamId teamId) {
95  				this.object = source;
96  				this.time = eventTime;
97  				this.teamId = teamId;
98  			}
99  			
100 			/**
101 			 * Simulation time in MILLI SECONDS !!!
102 			 */ 
103 			@Override
104 			public long getSimTime() {
105 				return time;
106 			}
107 	
108 			@Override
109 			public IWorldObject getObject() {
110 				return object;
111 			}
112 	
113 			@Override
114 			public WorldObjectId getId() {
115 				return object.getId();
116 			}
117 	
118 			@Override
119 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
120 				return new AliveMessageLocalImpl.AliveMessageLocalUpdate
121     ((AliveMessageLocal)object.getLocal(), time);
122 			}
123 	
124 			@Override
125 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
126 				return new AliveMessageSharedImpl.AliveMessageSharedUpdate
127     ((AliveMessageShared)object.getShared(), time, teamId);
128 			}
129 	
130 			@Override
131 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
132 				return new AliveMessageStaticImpl.AliveMessageStaticUpdate
133     ((AliveMessageStatic)object.getStatic(), time);
134 			}
135 			
136 		}
137     
138  		
139  	    public String toString() {
140             return
141             	super.toString() + "[" +
142             	
143 		              			"Time = " + String.valueOf(getTime()
144  	) + " | " + 
145 		              		
146 				"]";           		
147         }
148  	
149  		
150  		public String toHtmlString() {
151  			return super.toString() + "[<br/>" +
152             	
153 		              			"<b>Time</b> = " + String.valueOf(getTime()
154  	) + " <br/> " + 
155 		              		
156 				"<br/>]";     
157 		}
158  	 
159  	    public String toJsonLiteral() {
160             return "AliveMessage(null, "
161             		
162                    + ")";
163         }
164  	
165  		
166  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
167         	
168 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
169 		
170 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
171 	        
172 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
173  	
174 		}
175