1 package cz.cuni.amis.pogamut.usar2004.communication.messages.usarinfomessages;
2
3 import java.util.*;
4 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
5 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
6 import cz.cuni.amis.pogamut.usar2004.communication.messages.*;
7 import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
8
9
10
11
12
13
14
15
16
17
18 public class ConfigurationMessage extends GBEvent implements IWorldEvent, IWorldChangeEvent
19 {
20 public ConfigurationMessage(String Type, double MaxFrontSteer, double MaxRearSteer, double Mass, String SteeringType)
21 {
22 this.Type = Type;
23 this.Mass = Mass;
24 this.MaxFrontSteer = MaxFrontSteer;
25 this.MaxRearSteer = MaxRearSteer;
26 this.SteeringType = SteeringType;
27 }
28
29
30
31 public static final String PROTOTYPE = "CONF {Type text} {Mass 0} {MaxFrontSteer 0} {MaxRearSteer 0} {SteeringType text}";
32 protected String Type = null;
33
34
35
36
37
38
39
40
41 public String getType()
42 {
43 return Type;
44 }
45
46
47 protected String Name = null;
48
49
50
51
52
53
54 public String getName()
55 {
56 return Name;
57 }
58 protected String SteeringType = null;
59
60
61
62
63
64
65
66 public String getSteeringType()
67 {
68 return SteeringType;
69 }
70 protected double Mass = 0;
71
72
73
74
75
76
77 public double getMass()
78 {
79 return Mass;
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93 protected double MaxFrontSteer = 0;
94
95
96
97
98
99
100
101 public double getMaxFrontSteer()
102 {
103 return MaxFrontSteer;
104 }
105 protected double MaxRearSteer = 0;
106
107
108
109
110
111
112
113 public double getMaxRearSteer()
114 {
115 return MaxRearSteer;
116 }
117
118
119
120
121 protected Map<String, String> Features = new HashMap<String, String>();
122
123
124
125
126
127
128
129
130
131
132
133
134
135 public Map<String, String> getFeatures()
136 {
137 return Features;
138 }
139 protected List<String> Names = new ArrayList<String>();
140
141
142
143
144
145
146
147
148
149
150
151
152 public List<String> getNames()
153 {
154 return Names;
155 }
156 protected List<String> Opcodes = new ArrayList<String>();
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171 public List<String> getOpcodes()
172 {
173 return Opcodes;
174 }
175 protected List<Double> MaxVals = new ArrayList<Double>();
176
177
178
179
180
181
182
183 public List<Double> getMaxVals()
184 {
185 return MaxVals;
186 }
187 protected List<Double> MinVals = new ArrayList<Double>();
188
189
190
191
192
193
194
195 public List<Double> getMinVals()
196 {
197 return MinVals;
198 }
199
200
201
202 protected List<Integer> Links = new ArrayList<Integer>();
203
204
205
206
207
208
209
210
211 public List<Integer> getLinks()
212 {
213 return Links;
214 }
215 protected List<String> JointTypes = new ArrayList<String>();
216
217
218
219
220
221
222
223 public List<String> getJointTypes()
224 {
225 return JointTypes;
226 }
227 protected List<Double> MaxSpeeds = new ArrayList<Double>();
228
229
230
231
232
233
234 public List<Double> getMaxSpeeds()
235 {
236 return MaxSpeeds;
237 }
238 protected List<Double> MaxTorques = new ArrayList<Double>();
239
240
241
242
243
244
245 public List<Double> getMaxTorques()
246 {
247 return MaxTorques;
248 }
249 protected List<Double> MaxRanges = new ArrayList<Double>();
250
251
252
253
254
255
256
257
258 public List<Double> getMaxRanges()
259 {
260 return MaxRanges;
261 }
262 protected List<Double> MinRanges = new ArrayList<Double>();
263
264
265
266
267
268
269
270
271 public List<Double> getMinRanges()
272 {
273 return MinRanges;
274 }
275
276
277
278
279 public ConfigurationMessage(ConfigurationMessage original)
280 {
281 this.Type = original.Type;
282 this.Mass = original.Mass;
283 this.MaxFrontSteer = original.MaxFrontSteer;
284 this.MaxRearSteer = original.MaxRearSteer;
285 this.SteeringType = original.SteeringType;
286 this.JointTypes.addAll(original.JointTypes);
287 this.Links.addAll(original.Links);
288 this.MaxRanges.addAll(original.MaxRanges);
289 this.MaxSpeeds.addAll(original.MaxSpeeds);
290 this.MaxTorques.addAll(original.MaxTorques);
291 this.MaxVals.addAll(original.MaxVals);
292 this.Features.putAll(original.Features);
293 this.Names.addAll(original.Names);
294 this.Opcodes.addAll(original.Opcodes);
295 this.MinVals.addAll(original.MinVals);
296 this.MinRanges.addAll(original.MinRanges);
297 this.Name = original.Name;
298 }
299
300
301
302
303
304 public ConfigurationMessage()
305 {
306 }
307
308 @Override
309 public String toString()
310 {
311 StringBuilder buf = new StringBuilder();
312 buf.append(super.toString() + " | "
313 + "Type = "
314 + String.valueOf(Type) + " | "
315 + "MaxFrontSteer = "
316 + String.valueOf(MaxFrontSteer) + " | "
317 + "MaxRearSteer = "
318 + String.valueOf(MaxRearSteer) + " | "
319 + "Mass = "
320 + String.valueOf(Mass) + " | ");
321
322 if(SteeringType != null)
323 {
324 buf.append("SteeringType = ").append(String.valueOf(SteeringType)).append(" | ");
325 }
326
327 if(!JointTypes.isEmpty())
328 {
329 for(String i : JointTypes)
330 {
331 buf.append("JointType = ").append(i).append(" ");
332 }
333 buf.append(" | ");
334 }
335
336
337
338 if(!Links.isEmpty())
339 {
340 for(Integer i : Links)
341 {
342 buf.append("Link = ").append(i.toString()).append(" ");
343 }
344 buf.append(" | ");
345 }
346
347
348 if(!MaxRanges.isEmpty())
349 {
350 for(Double i : MaxRanges)
351 {
352 buf.append("MaxRange = ").append(i.toString()).append(" ");
353 }
354 buf.append(" | ");
355 }
356
357
358 if(!MaxSpeeds.isEmpty())
359 {
360 for(Double i : MaxSpeeds)
361 {
362 buf.append("MaxSpeed = ").append(i.toString()).append(" ");
363 }
364 buf.append(" | ");
365 }
366
367
368 if(!MaxTorques.isEmpty())
369 {
370 for(Double i : MaxTorques)
371 {
372 buf.append("MaxTorque = ").append(i.toString()).append(" ");
373 }
374 buf.append(" | ");
375 }
376
377
378 if(!MaxVals.isEmpty())
379 {
380 for(Double i : MaxVals)
381 {
382 buf.append("MaxVal = ").append(i.toString()).append(" ");
383 }
384 buf.append(" | ");
385 }
386
387
388 if(!Names.isEmpty())
389 {
390 for(String i : Names)
391 {
392 buf.append("Name = ").append(i.toString()).append(" ");
393 }
394 buf.append(" | ");
395 }
396
397
398 if(!Opcodes.isEmpty())
399 {
400 for(String i : Opcodes)
401 {
402 buf.append("Opcode = ").append(i.toString()).append(" ");
403 }
404 buf.append(" | ");
405 }
406
407
408
409 if(!MinVals.isEmpty())
410 {
411 for(Double i : MinVals)
412 {
413 buf.append("MinVal = ").append(i.toString()).append(" ");
414 }
415 buf.append(" | ");
416 }
417
418
419 if(!MinRanges.isEmpty())
420 {
421 for(Double i : MinRanges)
422 {
423 buf.append("MinRange = ").append(i.toString()).append(" ");
424 }
425 buf.append(" | ");
426 }
427
428 if(Name != null)
429 {
430 buf.append("Name = ").append(Name).append(" ");
431 buf.append(" | ");
432 }
433
434
435
436 if(!Features.isEmpty())
437 {
438 Iterator it = Features.entrySet().iterator();
439 while(it.hasNext())
440 {
441 Map.Entry en = (Map.Entry) it.next();
442 buf.append(" ").append(en.getKey()).append(" ").append(en.getValue()).append(",");
443 }
444 buf.append(" | ");
445 }
446
447 return buf.toString();
448 }
449
450
451
452
453
454
455 public String toHtmlString()
456 {
457 StringBuilder buf = new StringBuilder();
458 buf.append(super.toString()
459 + "<b>Type</b> : "
460 + String.valueOf(Type)
461 + " <br/> "
462 + "<b>Mass</b> : "
463 + String.valueOf(Mass)
464 + " <br/> "
465 + "<b>MaxFrontSteer</b> : "
466 + String.valueOf(MaxFrontSteer)
467 + " <br/> "
468 + "<b>MaxRearSteer</b> : "
469 + String.valueOf(MaxRearSteer)
470 + " <br/> "
471 + "<b>SteeringType</b> : "
472 + String.valueOf(SteeringType)
473 + " <br/> ");
474
475 if(!JointTypes.isEmpty())
476 {
477 for(String i : JointTypes)
478 {
479 buf.append("<b>JointType</b> : ").append(i).append(" ");
480 }
481 }
482
483 buf.append(" <br/> ");
484
485
486 if(!Links.isEmpty())
487 {
488 for(Integer i : Links)
489 {
490 buf.append("<b>Link</b> : ").append(i.toString()).append(" ");
491 }
492 }
493
494 buf.append(" <br/> ");
495
496 if(!MaxRanges.isEmpty())
497 {
498 for(Double i : MaxRanges)
499 {
500 buf.append("<b>MaxRange</b> : ").append(i.toString()).append(" ");
501 }
502 }
503
504 buf.append(" <br/> ");
505
506 if(!MaxSpeeds.isEmpty())
507 {
508 for(Double i : MaxSpeeds)
509 {
510 buf.append("<b>MaxSpeed</b> : ").append(i.toString()).append(" ");
511 }
512 }
513
514 buf.append(" <br/> ");
515
516 if(!MaxTorques.isEmpty())
517 {
518 for(Double i : MaxTorques)
519 {
520 buf.append("<b>MaxTorque</b> : ").append(i.toString()).append(" ");
521 }
522 }
523
524 buf.append(" <br/> ");
525
526 if(!MaxVals.isEmpty())
527 {
528 for(Double i : MaxVals)
529 {
530 buf.append("<b>MaxVal</b> : ").append(i.toString()).append(" ");
531 }
532 }
533
534 buf.append(" <br/> ");
535
536 if(!Names.isEmpty())
537 {
538 for(String i : Names)
539 {
540 buf.append("<b>Name</b> : ").append(i.toString()).append(" ");
541 }
542 }
543
544 buf.append(" <br/> ");
545
546 if(!Opcodes.isEmpty())
547 {
548 for(String i : Opcodes)
549 {
550 buf.append("<b>Opcode</b> : ").append(i.toString()).append(" ");
551 }
552 }
553
554
555 buf.append(" <br/> ");
556
557 if(!MinVals.isEmpty())
558 {
559 for(Double i : MinVals)
560 {
561 buf.append("<b>MinVal</b> : ").append(i.toString()).append(" ");
562 }
563 }
564
565 buf.append(" <br/> ");
566
567 if(!MinRanges.isEmpty())
568 {
569 for(Double i : MinRanges)
570 {
571 buf.append("<b>MinRange</b> : ").append(i.toString()).append(" ");
572 }
573 }
574 buf.append(" <br/> ");
575
576 if(Name != null)
577 {
578 buf.append("<b>Name</b> : ").append(Name).append(" ");
579 }
580
581 buf.append(" <br/> ");
582
583
584 if(!Features.isEmpty())
585 {
586 Iterator it = Features.entrySet().iterator();
587 while(it.hasNext())
588 {
589 Map.Entry en = (Map.Entry) it.next();
590 buf.append("<b>").append(en.getKey()).append("</b> : ").append(en.getValue()).append(",");
591 }
592 }
593
594 buf.append(" <br/> ");
595 return buf.toString();
596 }
597 }