1 package cz.cuni.amis.pogamut.usar2004.agent.module.geometry; 2 3 import cz.cuni.amis.pogamut.base3d.worldview.object.Location; 4 import cz.cuni.amis.pogamut.base3d.worldview.object.Rotation; 5 import cz.cuni.amis.pogamut.usar2004.agent.module.datatypes.GeometryType; 6 import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.SensorMount; 7 import java.util.List; 8 9 /** 10 * Geometry message representative for Sensors and Effecters. 11 * 12 * @author vejmanm 13 */ 14 public class GeoSensorEffecter extends SuperGeometry 15 { 16 public static final GeometryType type = GeometryType.SENSOR_EFFECTER; 17 18 /** 19 * Ctor. Geometry type describes particular subject about which we 20 * want to know about. It is used to distinguish incoming message from the 21 * server. 22 */ 23 public GeoSensorEffecter() 24 { 25 super(type); 26 } 27 28 /** 29 * Returns size of collection of sensor mounts. 30 * 31 * @return Returns size of collection of sensor mounts. 32 */ 33 public int getSize() 34 { 35 return lastMessage.getSenEffGeo().size(); 36 } 37 38 /** 39 * Camera, Sensor and effecter mounts are composed from Name, Location, 40 * Orientaion and Mount name. Returns null if none matches. 41 * 42 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 43 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 44 * 45 * @return Returns a Lotaion of sensor mount matching input <b>Name</b>. 46 */ 47 public Location getLocationBy(String Name) 48 { 49 SensorMount sen = getSensorEffecterBy(Name); 50 if(sen == null) 51 { 52 return null; 53 } 54 return sen.getLocation(); 55 } 56 57 /** 58 * Camera, Sensor and effecter mounts are composed from Name, Location, 59 * Orientaion and Mount name. Returns null if none matches. 60 * 61 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 62 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 63 * 64 * @return Returns a Location of sensor mount at given index. 65 */ 66 public Location getLocationAt(int index) 67 { 68 SensorMount sen = getSensorEffecterAt(index); 69 if(sen == null) 70 { 71 return null; 72 } 73 return sen.getLocation(); 74 } 75 76 /** 77 * Camera, Sensor and effecter mounts are composed from Name, Location, 78 * Orientaion and Mount name. Returns null if none matches. 79 * 80 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 81 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 82 * 83 * @return Returns a Mount name of sensor mount matching input <b>Name</b>. 84 */ 85 public String getMountBy(String Name) 86 { 87 SensorMount sen = getSensorEffecterBy(Name); 88 if(sen == null) 89 { 90 return null; 91 } 92 return sen.getMount(); 93 } 94 95 /** 96 * Camera, Sensor and effecter mounts are composed from Name, Location, 97 * Orientaion and Mount name. Returns null if none matches. 98 * 99 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 100 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 101 * 102 * @return Returns a Mount name of sensor mount at given index. 103 */ 104 public String getMountAt(int index) 105 { 106 SensorMount sen = getSensorEffecterAt(index); 107 if(sen == null) 108 { 109 return null; 110 } 111 return sen.getMount(); 112 } 113 114 /** 115 * Camera, Sensor and effecter mounts are composed from Name, Location, 116 * Orientaion and Mount name. Returns null if none matches. 117 * 118 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 119 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 120 * 121 * @return Returns an orientation of sensor mount matching input 122 * <b>Name</b>. 123 */ 124 public Rotation getOrientationBy(String Name) 125 { 126 SensorMount sen = getSensorEffecterBy(Name); 127 if(sen == null) 128 { 129 return null; 130 } 131 return sen.getOrientation(); 132 } 133 134 /** 135 * Camera, Sensor and effecter mounts are composed from Name, Location, 136 * Orientaion and Mount name. Returns null if none matches. 137 * 138 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 139 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 140 * 141 * @return Returns an orientation of sensor mount at given index. 142 */ 143 public Rotation getOrientationAt(int index) 144 { 145 SensorMount sen = getSensorEffecterAt(index); 146 if(sen == null) 147 { 148 return null; 149 } 150 return sen.getOrientation(); 151 } 152 153 /** 154 * Camera, Sensor and effecter mounts are composed from Name, Location, 155 * Orientaion and Mount name. 156 * 157 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 158 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 159 * 160 * @return Returns a sensor mount matching an input <b>Name</b>. 161 */ 162 public SensorMount getSensorEffecterBy(String Name) 163 { 164 for(SensorMount item : lastMessage.getSenEffGeo()) 165 { 166 if(item.getName().equalsIgnoreCase(Name)) 167 { 168 return item; 169 } 170 } 171 return null; 172 } 173 174 /** 175 * Camera, Sensor and effecter mounts are composed from Name, Location, 176 * Orientaion and Mount name. 177 * 178 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 179 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 180 * 181 * @return Returns a sensor mount at given index. 182 */ 183 public SensorMount getSensorEffecterAt(int index) 184 { 185 if(index < getSize()) 186 { 187 return lastMessage.getSenEffGeo().get(index); 188 } 189 return null; 190 } 191 192 /** 193 * Camera, Sensor and effecter mounts are composed from Name, Location, 194 * Orientaion and Mount name. 195 * 196 * Example: GEO {Type Camera} {Name Camera Location 0.0820,0.0002,0.0613 197 * Orientation 0.0000,-0.0000,0.0000 Mount CameraTilt} 198 * 199 * @return Returns a collection of sensor mounts. 200 */ 201 public List<SensorMount> getSensorMountCollection() 202 { 203 return lastMessage.getSenEffGeo(); 204 } 205 }