1 package cz.cuni.amis.pogamut.usar2004.communication.messages.usarcommands;
2
3 import cz.cuni.amis.pogamut.base.communication.messages.*;
4 import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
5
6 /**
7 *
8 * This command is used to manage the viewpoint.
9 *
10 *
11 *
12 *
13 * This command sets the viewpoint of the specified Unreal Client to a robot’s
14 * camera. The unreal client is defined by ‘{Client ip}’ where ‘ip’ is the
15 * client’s IP address. Please note USARSim doesn’t support the loopback ip
16 * address. So don’t use “127.0.0.1” as the parameter. The robot is specified by
17 * ‘{Robot string}’ where ‘string’ is the robot’s name. And the camera is
18 * specified by ‘{Name string}’ where ‘string’ is the camera’s name. Once the
19 * client’s viewpoint is set, we can NOT manually change it until we release the
20 * viewpoint control. To release the control, we send another SET command
21 * without ‘{robot name}’. For example, we can send “SET {Type Camera} {Client
22 * 10.0.0.2}” to release the viewpoint control on client 10.0.0.2.
23 *
24 *
25 * We can use this command at anytime and anyplace. This command can be sent
26 * either from a robot’s controller or from other applications such as the
27 * ImageServer.
28 *
29 * Corresponding GameBots command is SET.
30 *
31 */
32 public class SetViewpoint extends CommandMessage
33 {
34 //constructor for the joints
35 public SetViewpoint(String Robot, String Name, String Client)
36 {
37 this.Robot = Robot;
38 this.Name = Name;
39 this.Client = Client;
40 }
41
42 /**
43 * <p></p>WARNING: this is empty-command constructor, you have to use
44 * Setters to fill it up!
45 */
46 public SetViewpoint()
47 {
48 }
49 /////// Properties BEGIN
50 protected String Type = "Camera";
51
52 public String getType()
53 {
54 return Type;
55 }
56 //Cameras name
57 protected String Name = null;
58
59 public String getName()
60 {
61 return Name;
62 }
63
64 public SetViewpoint SetViewpointName(String Name)
65 {
66 this.Name = Name;
67 return this;
68 }
69 //Robots name
70 protected String Robot = null;
71
72 public String getRobot()
73 {
74 return Robot;
75 }
76
77 public SetViewpoint SetViewpointRobot(String Robot)
78 {
79 this.Robot = Robot;
80 return this;
81 }
82 /*
83 * IP address: NOTE: USARSim doesn’t support the loopback ip address. Please
84 * don’t use “127.0.0.1” as the parameter.
85 */
86 protected String Client = null;
87
88 public String getClient()
89 {
90 return Client;
91 }
92
93 public SetViewpoint SetViewpointClient(String Client)
94 {
95 this.Client = Client;
96 return this;
97 }
98
99 /////// Properties END
100 /////// Extra Java code BEGIN
101 /////// Additional code from xslt BEGIN
102 /////// Additional code from xslt END
103 /////// Extra Java from XML BEGIN
104 /////// Extra Java from XML END
105 /////// Extra Java code END
106 /**
107 * Cloning constructor.
108 */
109 public SetViewpoint(SetViewpoint original)
110 {
111 this.Name = original.Name;
112 this.Robot = original.Robot;
113 this.Client = original.Client;
114 }
115
116 @Override
117 public String toString()
118 {
119 return toMessage();
120 }
121
122 public String toHtmlString()
123 {
124 return super.toString()
125 + "<b>Type</b> : "
126 + String.valueOf(Type)
127 + " <br/> "
128 + "<b>Robot</b> : "
129 + String.valueOf(Robot)
130 + " <br/> "
131 + "<b>Name</b> : "
132 + String.valueOf(Name)
133 + " <br/> "
134 + "<b>Client</b> : "
135 + String.valueOf(Client)
136 + " <br/> "
137 + "";
138 }
139
140 public String toMessage()
141 {
142
143 StringBuilder buf = new StringBuilder();
144 buf.append("SET");
145
146 if(Type != null)
147 {
148 buf.append(" {Type ").append(Type).append("}");
149 }
150
151 if(Robot != null)
152 {
153 buf.append(" {Robot ").append(Robot).append("}");
154 }
155
156 if(Name != null)
157 {
158 buf.append(" {Name ").append(Name).append("}");
159 }
160
161 if(Client != null)
162 {
163 buf.append(" {Client ").append(Client.toString()).append("}");
164 }
165
166
167 return buf.toString();
168 }
169 }