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 AliveMessageLocalImpl
31 extends
32 AliveMessageLocal
33 {
34
35
36
37
38
39
40 public AliveMessageLocalImpl()
41 {
42 }
43
44
45
46
47
48
49 public AliveMessageLocalImpl(AliveMessage original) {
50
51 this.Time = original.getTime()
52 ;
53
54 this.SimTime = original.getSimTime();
55 }
56
57
58
59
60
61
62 public AliveMessageLocalImpl(AliveMessageLocalImpl original) {
63
64 this.Time = original.getTime()
65 ;
66
67 this.SimTime = original.getSimTime();
68 }
69
70
71
72
73
74
75 public AliveMessageLocalImpl(AliveMessageLocal original) {
76
77 this.Time = original.getTime()
78 ;
79
80 }
81
82
83 public UnrealId getId() {
84 return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AliveMessage.AliveMessageId;
85 }
86
87
88 @Override
89 public void setSimTime(long SimTime) {
90 super.setSimTime(SimTime);
91 }
92
93 @Override
94 public
95 AliveMessageLocalImpl clone() {
96 return new
97 AliveMessageLocalImpl(this);
98 }
99
100
101
102
103
104
105
106
107 protected
108 double Time =
109 0;
110
111
112
113
114
115
116 public double getTime()
117 {
118 return Time;
119 }
120
121
122
123
124
125 public AliveMessageLocalImpl getLocal() {
126 return this;
127 }
128 public ISharedWorldObject getShared() {
129 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
130 }
131 public IStaticWorldObject getStatic() {
132 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
133 }
134
135 public static class AliveMessageLocalUpdate
136 implements ILocalWorldObjectUpdatedEvent, IGBWorldObjectEvent
137 {
138 protected long time;
139
140 protected AliveMessageLocal data = null;
141
142 public AliveMessageLocalUpdate
143 (AliveMessageLocal moverLocal, long time)
144 {
145 this.data = moverLocal;
146 this.time = time;
147 }
148
149 @Override
150 public IWorldObjectUpdateResult<ILocalWorldObject> update(
151 ILocalWorldObject object)
152 {
153 if ( object == null)
154 {
155 data = new AliveMessageLocalImpl(data);
156 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
157 }
158 if ( object instanceof AliveMessageLocalImpl )
159 {
160 AliveMessageLocalImpl toUpdate = (AliveMessageLocalImpl)object;
161
162 boolean updated = false;
163
164
165
166 if (toUpdate.Time != data.getTime()
167 ) {
168 toUpdate.Time=data.getTime()
169 ;
170 updated = true;
171 }
172
173
174 data = toUpdate;
175
176 if ( updated )
177 {
178 toUpdate.SimTime = this.time;
179 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, data);
180 }
181
182 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
183 }
184 throw new PogamutException("Unsupported object type for update. Expected AliveMessageLocalImpl for object " + object.getId() +", not object of class " + object.getClass().getSimpleName() + ".", this);
185 }
186
187
188
189
190 @Override
191 public long getSimTime() {
192 return this.time;
193 }
194
195 @Override
196 public IWorldObject getObject() {
197 return data;
198 }
199
200 @Override
201 public WorldObjectId getId() {
202 return data.getId();
203 }
204
205 }
206
207
208 public String toString() {
209 return
210 super.toString() + "[" +
211
212 "Time = " + String.valueOf(getTime()
213 ) + " | " +
214
215 "]";
216 }
217
218
219 public String toHtmlString() {
220 return super.toString() + "[<br/>" +
221
222 "<b>Time</b> = " + String.valueOf(getTime()
223 ) + " <br/> " +
224
225 "<br/>]";
226 }
227
228
229
230
231
232
233
234
235
236
237 }
238