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 public class LocationUpdateMessage
28 extends
29 LocationUpdate
30 implements IWorldObjectUpdatedEvent, ICompositeWorldObjectUpdatedEvent
31
32 {
33
34
35
36
37
38
39 public LocationUpdateMessage()
40 {
41 }
42
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
71
72
73
74
75
76
77
78
79
80
81 public LocationUpdateMessage(
82 UnrealId Id, Location Loc, Velocity Vel, Rotation Rot
83 ) {
84
85 this.Id = Id;
86
87 this.Loc = Loc;
88
89 this.Vel = Vel;
90
91 this.Rot = Rot;
92
93 }
94
95
96
97
98
99
100 public LocationUpdateMessage(LocationUpdateMessage original) {
101
102 this.Id = original.getId()
103 ;
104
105 this.Loc = original.getLoc()
106 ;
107
108 this.Vel = original.getVel()
109 ;
110
111 this.Rot = original.getRot()
112 ;
113
114 this.TeamId = original.getTeamId();
115
116 this.SimTime = original.getSimTime();
117 }
118
119
120 protected ITeamId TeamId;
121
122
123
124
125 protected void setTeamId(ITeamId TeamId) {
126 this.TeamId = TeamId;
127 }
128
129 public ITeamId getTeamId() {
130 return TeamId;
131 }
132
133
134
135
136
137
138
139 protected
140 UnrealId Id =
141 null;
142
143
144
145
146
147 protected boolean Id_Set = false;
148
149 @Override
150
151
152
153
154 public UnrealId getId()
155 {
156 return Id;
157 }
158
159
160
161
162
163
164
165 protected
166 Location Loc =
167 null;
168
169
170
171
172
173 protected boolean Loc_Set = false;
174
175 @Override
176
177
178
179
180
181
182 public Location getLoc()
183 {
184 return Loc;
185 }
186
187
188
189
190
191
192
193
194 protected
195 Velocity Vel =
196 null;
197
198
199
200
201
202 protected boolean Vel_Set = false;
203
204 @Override
205
206
207
208
209
210
211
212 public Velocity getVel()
213 {
214 return Vel;
215 }
216
217
218
219
220
221
222
223 protected
224 Rotation Rot =
225 null;
226
227
228
229
230
231 protected boolean Rot_Set = false;
232
233 @Override
234
235
236
237
238
239
240 public Rotation getRot()
241 {
242 return Rot;
243 }
244
245
246 private LocationUpdateLocal localPart = null;
247
248 @Override
249 public LocationUpdateLocal
250 getLocal() {
251 if (localPart != null) return localPart;
252 return localPart = new
253 LocationUpdateLocalMessage();
254 }
255
256 private LocationUpdateShared sharedPart = null;
257
258 @Override
259 public LocationUpdateShared
260 getShared() {
261 if (sharedPart != null) return sharedPart;
262 return sharedPart = new
263 LocationUpdateSharedMessage();
264 }
265
266 private LocationUpdateStatic staticPart = null;
267
268 @Override
269 public LocationUpdateStatic
270 getStatic() {
271 if (staticPart != null) return staticPart;
272 return staticPart = new
273 LocationUpdateStaticMessage();
274 }
275
276
277
278
279
280
281
282
283
284
285
286
287
288 public class LocationUpdateLocalMessage
289 extends
290 LocationUpdateLocal
291 {
292
293 @Override
294 public
295 LocationUpdateLocalMessage clone() {
296 return this;
297 }
298
299 public LocationUpdateLocalMessage getLocal() {
300 return this;
301 }
302 public ISharedWorldObject getShared() {
303 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
304 }
305 public IStaticWorldObject getStatic() {
306 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
307 }
308
309
310
311
312 public UnrealId getId()
313 {
314 return Id;
315 }
316
317
318
319
320
321
322 public Location getLoc()
323 {
324 return Loc;
325 }
326
327
328
329
330
331
332
333 public Velocity getVel()
334 {
335 return Vel;
336 }
337
338
339
340
341
342
343 public Rotation getRot()
344 {
345 return Rot;
346 }
347
348
349 public String toString() {
350 return
351 super.toString() + "[" +
352
353 "Id = " + String.valueOf(getId()
354 ) + " | " +
355
356 "Loc = " + String.valueOf(getLoc()
357 ) + " | " +
358
359 "Vel = " + String.valueOf(getVel()
360 ) + " | " +
361
362 "Rot = " + String.valueOf(getRot()
363 ) + " | " +
364
365 "]";
366 }
367
368
369 public String toHtmlString() {
370 return super.toString() + "[<br/>" +
371
372 "<b>Id</b> = " + String.valueOf(getId()
373 ) + " <br/> " +
374
375 "<b>Loc</b> = " + String.valueOf(getLoc()
376 ) + " <br/> " +
377
378 "<b>Vel</b> = " + String.valueOf(getVel()
379 ) + " <br/> " +
380
381 "<b>Rot</b> = " + String.valueOf(getRot()
382 ) + " <br/> " +
383
384 "<br/>]";
385 }
386
387
388
389
390
391
392
393
394
395
396 }
397
398
399
400
401
402
403
404
405
406
407
408
409
410 public class LocationUpdateStaticMessage
411 extends
412 LocationUpdateStatic
413 {
414
415 @Override
416 public
417 LocationUpdateStaticMessage clone() {
418 return this;
419 }
420
421
422
423
424 public UnrealId getId()
425 {
426 return Id;
427 }
428
429
430 @Override
431 public boolean isDifferentFrom(IStaticWorldObject other)
432 {
433 if (other == null)
434 {
435 return true;
436 }
437 else if (other == this)
438 {
439 return false;
440 }
441 else
442 {
443 LocationUpdateStatic obj = (LocationUpdateStatic) other;
444
445
446 if ( !(
447 AdvancedEquals.equalsOrNull(this.getId()
448 , obj.getId()
449 )
450 ) )
451 {
452 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class LocationUpdateStatic");
453 return true;
454 }
455
456 }
457 return false;
458 }
459
460
461 public String toString() {
462 return
463 super.toString() + "[" +
464
465 "Id = " + String.valueOf(getId()
466 ) + " | " +
467
468 "]";
469 }
470
471
472 public String toHtmlString() {
473 return super.toString() + "[<br/>" +
474
475 "<b>Id</b> = " + String.valueOf(getId()
476 ) + " <br/> " +
477
478 "<br/>]";
479 }
480
481
482
483
484
485
486
487
488
489
490 }
491
492
493
494
495
496
497
498
499
500
501
502
503
504 public class LocationUpdateSharedMessage
505 extends
506 LocationUpdateShared
507 {
508
509
510
511 public LocationUpdateSharedMessage()
512 {
513
514 }
515
516 @Override
517 public
518 LocationUpdateSharedMessage clone() {
519 return this;
520 }
521
522
523
524
525 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
526 0
527 );
528
529 @Override
530 public ISharedProperty getProperty(PropertyId id) {
531 return propertyMap.get(id);
532 }
533
534 @Override
535 public Map<PropertyId, ISharedProperty> getProperties() {
536 return propertyMap;
537 }
538
539
540
541
542
543
544 public UnrealId getId()
545 {
546 return Id;
547 }
548
549
550 public String toString() {
551 return
552 super.toString() + "[" +
553
554 "Id = " + String.valueOf(getId()
555 ) + " | " +
556
557 "]";
558 }
559
560
561 public String toHtmlString() {
562 return super.toString() + "[<br/>" +
563
564 "<b>Id</b> = " + String.valueOf(getId()
565 ) + " <br/> " +
566
567 "<br/>]";
568 }
569
570
571
572
573
574
575
576
577
578
579 }
580
581
582
583
584 @Override
585 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject object) {
586 if (object == null)
587 {
588 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.CREATED, this);
589 }
590 if (!( object instanceof LocationUpdateMessage) ) {
591 throw new PogamutException("Can't update different class than LocationUpdateMessage, got class " + object.getClass().getSimpleName() + "!", this);
592 }
593 LocationUpdateMessage toUpdate = (LocationUpdateMessage)object;
594
595 boolean updated = false;
596
597
598
599 if (!SafeEquals.equals(toUpdate.Loc, getLoc()
600 )) {
601 toUpdate.Loc=getLoc()
602 ;
603 updated = true;
604 }
605
606 if (!SafeEquals.equals(toUpdate.Vel, getVel()
607 )) {
608 toUpdate.Vel=getVel()
609 ;
610 updated = true;
611 }
612
613 if (!SafeEquals.equals(toUpdate.Rot, getRot()
614 )) {
615 toUpdate.Rot=getRot()
616 ;
617 updated = true;
618 }
619
620
621
622
623
624
625 toUpdate.SimTime = SimTime;
626
627 if (updated) {
628 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
629 } else {
630 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.SAME, toUpdate);
631 }
632 }
633
634 @Override
635 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
636 return new LocationUpdateLocalImpl.LocationUpdateLocalUpdate
637 (this.getLocal(), SimTime);
638 }
639
640 @Override
641 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
642 return new LocationUpdateSharedImpl.LocationUpdateSharedUpdate
643 (this.getShared(), SimTime, this.getTeamId());
644 }
645
646 @Override
647 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
648 return new LocationUpdateStaticImpl.LocationUpdateStaticUpdate
649 (this.getStatic(), SimTime);
650 }
651
652
653 public String toString() {
654 return
655 super.toString() + "[" +
656
657 "Id = " + String.valueOf(getId()
658 ) + " | " +
659
660 "Loc = " + String.valueOf(getLoc()
661 ) + " | " +
662
663 "Vel = " + String.valueOf(getVel()
664 ) + " | " +
665
666 "Rot = " + String.valueOf(getRot()
667 ) + " | " +
668
669 "]";
670 }
671
672
673 public String toHtmlString() {
674 return super.toString() + "[<br/>" +
675
676 "<b>Id</b> = " + String.valueOf(getId()
677 ) + " <br/> " +
678
679 "<b>Loc</b> = " + String.valueOf(getLoc()
680 ) + " <br/> " +
681
682 "<b>Vel</b> = " + String.valueOf(getVel()
683 ) + " <br/> " +
684
685 "<b>Rot</b> = " + String.valueOf(getRot()
686 ) + " <br/> " +
687
688 "<br/>]";
689 }
690
691
692
693
694
695
696
697
698
699
700 }
701