1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
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
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class AliveMessageMessage
31 extends
32 AliveMessage
33 implements IWorldObjectUpdatedEvent, ICompositeWorldObjectUpdatedEvent
34
35 {
36
37
38
39
40
41
42 public AliveMessageMessage()
43 {
44 }
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 public AliveMessageMessage(
71 double Time
72 ) {
73
74 this.Time = Time;
75
76 }
77
78
79
80
81
82
83 public AliveMessageMessage(AliveMessageMessage original) {
84
85 this.Time = original.getTime()
86 ;
87
88 this.TeamId = original.getTeamId();
89
90 this.SimTime = original.getSimTime();
91 }
92
93
94 public UnrealId getId() {
95 return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
96 }
97
98
99 protected ITeamId TeamId;
100
101
102
103
104 protected void setTeamId(ITeamId TeamId) {
105 this.TeamId = TeamId;
106 }
107
108 public ITeamId getTeamId() {
109 return TeamId;
110 }
111
112
113
114
115
116
117
118
119
120 protected
121 double Time =
122 0;
123
124
125
126
127
128 protected boolean Time_Set = false;
129
130 @Override
131
132
133
134
135
136
137 public double getTime()
138 {
139 return Time;
140 }
141
142
143 private AliveMessageLocal localPart = null;
144
145 @Override
146 public AliveMessageLocal
147 getLocal() {
148 if (localPart != null) return localPart;
149 return localPart = new
150 AliveMessageLocalMessage();
151 }
152
153 private AliveMessageShared sharedPart = null;
154
155 @Override
156 public AliveMessageShared
157 getShared() {
158 if (sharedPart != null) return sharedPart;
159 return sharedPart = new
160 AliveMessageSharedMessage();
161 }
162
163 private AliveMessageStatic staticPart = null;
164
165 @Override
166 public AliveMessageStatic
167 getStatic() {
168 if (staticPart != null) return staticPart;
169 return staticPart = new
170 AliveMessageStaticMessage();
171 }
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 public class AliveMessageLocalMessage
189 extends
190 AliveMessageLocal
191 {
192
193
194 public UnrealId getId() {
195 return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
196 }
197
198 @Override
199 public
200 AliveMessageLocalMessage clone() {
201 return this;
202 }
203
204 public AliveMessageLocalMessage getLocal() {
205 return this;
206 }
207 public ISharedWorldObject getShared() {
208 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
209 }
210 public IStaticWorldObject getStatic() {
211 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
212 }
213
214
215
216
217
218
219 public double getTime()
220 {
221 return Time;
222 }
223
224
225 public String toString() {
226 return
227 super.toString() + "[" +
228
229 "Time = " + String.valueOf(getTime()
230 ) + " | " +
231
232 "]";
233 }
234
235
236 public String toHtmlString() {
237 return super.toString() + "[<br/>" +
238
239 "<b>Time</b> = " + String.valueOf(getTime()
240 ) + " <br/> " +
241
242 "<br/>]";
243 }
244
245
246
247
248
249
250
251
252
253
254 }
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271 public class AliveMessageStaticMessage
272 extends
273 AliveMessageStatic
274 {
275
276
277 public UnrealId getId() {
278 return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
279 }
280
281 @Override
282 public
283 AliveMessageStaticMessage clone() {
284 return this;
285 }
286
287
288 @Override
289 public boolean isDifferentFrom(IStaticWorldObject other)
290 {
291 if (other == null)
292 {
293 return true;
294 }
295 else if (other == this)
296 {
297 return false;
298 }
299 else
300 {
301 AliveMessageStatic obj = (AliveMessageStatic) other;
302
303
304 }
305 return false;
306 }
307
308
309 public String toString() {
310 return
311 super.toString() + "[" +
312
313 "]";
314 }
315
316
317 public String toHtmlString() {
318 return super.toString() + "[<br/>" +
319
320 "<br/>]";
321 }
322
323
324
325
326
327
328
329
330
331
332 }
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349 public class AliveMessageSharedMessage
350 extends
351 AliveMessageShared
352 {
353
354
355
356 public AliveMessageSharedMessage()
357 {
358
359 }
360
361
362 public UnrealId getId() {
363 return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
364 }
365
366 @Override
367 public
368 AliveMessageSharedMessage clone() {
369 return this;
370 }
371
372
373
374
375 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
376 0
377 );
378
379 @Override
380 public ISharedProperty getProperty(PropertyId id) {
381 return propertyMap.get(id);
382 }
383
384 @Override
385 public Map<PropertyId, ISharedProperty> getProperties() {
386 return propertyMap;
387 }
388
389
390
391
392 public String toString() {
393 return
394 super.toString() + "[" +
395
396 "]";
397 }
398
399
400 public String toHtmlString() {
401 return super.toString() + "[<br/>" +
402
403 "<br/>]";
404 }
405
406
407
408
409
410
411
412
413
414
415 }
416
417
418
419
420 @Override
421 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject object) {
422 if (object == null)
423 {
424 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.CREATED, this);
425 }
426 if (!( object instanceof AliveMessageMessage) ) {
427 throw new PogamutException("Can't update different class than AliveMessageMessage, got class " + object.getClass().getSimpleName() + "!", this);
428 }
429 AliveMessageMessage toUpdate = (AliveMessageMessage)object;
430
431 boolean updated = false;
432
433
434
435 if (toUpdate.Time != getTime()
436 ) {
437 toUpdate.Time=getTime()
438 ;
439 updated = true;
440 }
441
442
443
444
445
446
447 toUpdate.SimTime = SimTime;
448
449 if (updated) {
450 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
451 } else {
452 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.SAME, toUpdate);
453 }
454 }
455
456 @Override
457 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
458 return new AliveMessageLocalImpl.AliveMessageLocalUpdate
459 (this.getLocal(), SimTime);
460 }
461
462 @Override
463 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
464 return new AliveMessageSharedImpl.AliveMessageSharedUpdate
465 (this.getShared(), SimTime, this.getTeamId());
466 }
467
468 @Override
469 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
470 return new AliveMessageStaticImpl.AliveMessageStaticUpdate
471 (this.getStatic(), SimTime);
472 }
473
474
475 public String toString() {
476 return
477 super.toString() + "[" +
478
479 "Time = " + String.valueOf(getTime()
480 ) + " | " +
481
482 "]";
483 }
484
485
486 public String toHtmlString() {
487 return super.toString() + "[<br/>" +
488
489 "<b>Time</b> = " + String.valueOf(getTime()
490 ) + " <br/> " +
491
492 "<br/>]";
493 }
494
495
496
497
498
499
500
501
502
503
504 }
505