1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2017-2018 German Aerospace Center (DLR) and others. 4 // TraaS module 5 // Copyright (C) 2016-2017 Dresden University of Technology 6 // This program and the accompanying materials 7 // are made available under the terms of the Eclipse Public License v2.0 8 // which accompanies this distribution, and is available at 9 // http://www.eclipse.org/legal/epl-v20.html 10 // SPDX-License-Identifier: EPL-2.0 11 /****************************************************************************/ 12 /// @file Vehicletype.java 13 /// @author Mario Krumnow 14 /// @author Evamarie Wiessner 15 /// @date 2016 16 /// @version $Id$ 17 /// 18 // 19 /****************************************************************************/ 20 package de.tudresden.sumo.cmd; 21 import de.tudresden.sumo.config.Constants; 22 import de.tudresden.sumo.util.SumoCommand; 23 import de.tudresden.ws.container.SumoColor; 24 25 /** 26 * 27 * @author Mario Krumnow 28 * @author Evamarie Wiessner 29 * 30 */ 31 32 public class Vehicletype { 33 34 //getter methods 35 36 /** 37 * Returns the maximum acceleration of the named vehicle class. 38 * @param typeID type id 39 * @return acceleration 40 */ getAccel(String typeID)41 public static SumoCommand getAccel(String typeID){ 42 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_ACCEL, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 43 } 44 45 /** 46 * Returns the number of all vehicle types in the network. 47 * @return number of vehicle types 48 */ 49 getIDCount()50 public static SumoCommand getIDCount(){ 51 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.ID_COUNT, "", Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_INTEGER); 52 } 53 54 /** 55 * Returns the vehicle type's color. 56 * @param typeID type id 57 * @return color color 58 */ getColor(String typeID)59 public static SumoCommand getColor(String typeID){ 60 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_COLOR, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_COLOR); 61 } 62 63 /** 64 * Returns the maximum deceleration of the names vehicle type. 65 * @param typeID type id 66 * @return deceleration 67 */ 68 getDecel(String typeID)69 public static SumoCommand getDecel(String typeID){ 70 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_DECEL, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 71 } 72 73 /** 74 * Returns the maximal physically possible deceleration in m/s^2 of vehicles of this type. 75 * @param typeID type id 76 * @return deceleration 77 */ 78 getEmergencyDecel(String typeID)79 public static SumoCommand getEmergencyDecel(String typeID){ 80 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_EMERGENCY_DECEL, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 81 } 82 83 /** 84 * Returns The preferred lateral alignment of the type 85 * @param typeID type id 86 * @return deceleration 87 */ 88 getLateralAlignment(String typeID)89 public static SumoCommand getLateralAlignment(String typeID){ 90 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_LATALIGNMENT, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRING); 91 } 92 93 /** 94 * Returns the height in m of vehicles of this type. 95 * @param typeID type id 96 * @return deceleration 97 */ 98 getHeight(String typeID)99 public static SumoCommand getHeight(String typeID){ 100 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_HEIGHT, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 101 } 102 103 104 /** 105 * Returns The preferred lateral alignment of the type 106 * @param typeID type id 107 * @return deceleration 108 */ 109 getApparentDecel(String typeID)110 public static SumoCommand getApparentDecel(String typeID){ 111 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_APPARENT_DECEL, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 112 } 113 114 115 /** 116 * Returns The desired lateral gap of this type at 50km/h in m 117 * @param typeID type id 118 * @return deceleration 119 */ 120 getMinGapLat(String typeID)121 public static SumoCommand getMinGapLat(String typeID){ 122 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_MINGAP_LAT, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 123 } 124 125 126 /** 127 * Returns the maximum lateral speed in m/s of this type. 128 * @param typeID type id 129 * @return deceleration 130 */ 131 getMaxSpeedLat(String typeID)132 public static SumoCommand getMaxSpeedLat(String typeID){ 133 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_MAXSPEED_LAT, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 134 } 135 136 /** 137 * Returns the emission class of the named vehicle type. 138 * @param typeID type id 139 * @return emission class 140 */ 141 getEmissionClass(String typeID)142 public static SumoCommand getEmissionClass(String typeID){ 143 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_EMISSIONCLASS, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRING); 144 } 145 146 /** 147 * Returns a list of all known vehicle types. 148 * @return list of vechicle types 149 */ 150 getIDList()151 public static SumoCommand getIDList(){ 152 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.TRACI_ID_LIST, "", Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRINGLIST); 153 } 154 155 /** 156 * getImperfection 157 * @param typeID type id 158 * @return imperfection 159 */ 160 getImperfection(String typeID)161 public static SumoCommand getImperfection(String typeID){ 162 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_IMPERFECTION, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 163 } 164 165 /** 166 * Returns the length of the named vehicle type. 167 * @param typeID type id 168 * @return length 169 */ 170 getLength(String typeID)171 public static SumoCommand getLength(String typeID){ 172 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_LENGTH, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 173 } 174 175 /** 176 * Return the maximum speed of the named vehicle type. 177 * @param typeID type id 178 * @return max speed 179 */ 180 getMaxSpeed(String typeID)181 public static SumoCommand getMaxSpeed(String typeID){ 182 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_MAXSPEED, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 183 } 184 185 /** 186 * Returns the minimum headway gap of the named vehicle type. 187 * @param typeID type id 188 * @return min gap 189 */ 190 getMinGap(String typeID)191 public static SumoCommand getMinGap(String typeID){ 192 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_MINGAP, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 193 } 194 195 /** 196 * Returns the chosen parameter 197 * 198 * @param typeID a string identifying the vehicle type 199 * @param param a string identifying the parameter 200 * 201 * @return the specific parameter 202 */ 203 getParameter(String typeID, String param)204 public static SumoCommand getParameter(String typeID, String param){ 205 Object[] array = new Object[]{param}; 206 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_PARAMETER, typeID, array, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRING); 207 } 208 209 /** 210 * Sets the chosen parameter 211 * 212 * @param vehID a string identifying the vehicle 213 * @param param a string identifying the parameter 214 * @param value a string identifying the new value 215 * 216 * @return SumoCommand 217 */ 218 setParameter(String typeID, String param, String value)219 public static SumoCommand setParameter(String typeID, String param, String value){ 220 Object[] array = new Object[]{param, value}; 221 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_PARAMETER, typeID, array); 222 } 223 224 /** 225 * getShapeClass 226 * @param typeID type id 227 * @return shape class 228 */ 229 getShapeClass(String typeID)230 public static SumoCommand getShapeClass(String typeID){ 231 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_SHAPECLASS, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRING); 232 } 233 234 /** 235 * Returns the speed deviation of the named vehicle type. 236 * @param typeID type id 237 * @return speed deviation 238 */ 239 getSpeedDeviation(String typeID)240 public static SumoCommand getSpeedDeviation(String typeID){ 241 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_SPEED_DEVIATION, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 242 } 243 244 /** 245 * Return the speed factor of the names vehicle type. 246 * @param typeID type id 247 * @return speed factor 248 */ 249 getSpeedFactor(String typeID)250 public static SumoCommand getSpeedFactor(String typeID){ 251 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_SPEED_FACTOR, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 252 } 253 254 /** 255 * getTau 256 * @param typeID type id 257 * @return tau 258 */ 259 getTau(String typeID)260 public static SumoCommand getTau(String typeID){ 261 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_TAU, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 262 } 263 264 /** 265 * Returns the vehicle class of the names vehicle type. 266 * @param typeID type id 267 * @return vehicle class 268 */ 269 getVehicleClass(String typeID)270 public static SumoCommand getVehicleClass(String typeID){ 271 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_VEHICLECLASS, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_STRING); 272 } 273 274 /** 275 * Returns the width of the named vehicle type. 276 * @param typeID type id 277 * @return width 278 */ 279 getWidth(String typeID)280 public static SumoCommand getWidth(String typeID){ 281 return new SumoCommand(Constants.CMD_GET_VEHICLETYPE_VARIABLE, Constants.VAR_WIDTH, typeID, Constants.RESPONSE_GET_VEHICLETYPE_VARIABLE, Constants.TYPE_DOUBLE); 282 } 283 284 //setter methods 285 286 /** 287 * Sets the vehicle type's wished maximum acceleration to the given value. 288 * @param typeID type id 289 * @param accel acceleration 290 * @return SumoCommand 291 */ setAccel(String typeID, double accel)292 public static SumoCommand setAccel(String typeID, double accel){ 293 294 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_ACCEL, typeID, accel); 295 } 296 297 298 /** 299 * Sets the vehicle type's color. 300 * @param typeID type id 301 * @param color color 302 * @return SumoCommand 303 */ setColor(String typeID, SumoColor color)304 public static SumoCommand setColor(String typeID, SumoColor color){ 305 306 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_COLOR, typeID, color); 307 } 308 309 /** 310 * Sets the vehicle type's wished maximum deceleration to the given value. 311 312 * @param typeID type id 313 * @param decel deceleration 314 * @return SumoCommand 315 */ setDecel(String typeID, double decel)316 public static SumoCommand setDecel(String typeID, double decel){ 317 318 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_DECEL, typeID, decel); 319 } 320 321 /** 322 * Sets the vehicle type's emission class to the given value. 323 * @param typeID type id 324 * @param clazz emission class 325 * @return SumoCommand 326 */ setEmissionClass(String typeID, String clazz)327 public static SumoCommand setEmissionClass(String typeID, String clazz){ 328 329 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_EMISSIONCLASS, typeID, clazz); 330 } 331 332 /** 333 * setImperfection 334 * @param typeID type id 335 * @param minGapLat minGapLat 336 * @return SumoCommand 337 */ setMinGapLat(String typeID, double minGapLat)338 public static SumoCommand setMinGapLat(String typeID, double minGapLat){ 339 340 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_MINGAP_LAT, typeID, minGapLat); 341 } 342 343 /** 344 * Sets the maximum lateral speed of this type. 345 * @param typeID type id 346 * @param speed speed 347 * @return SumoCommand 348 */ setMaxSpeedLat(String typeID, double speed)349 public static SumoCommand setMaxSpeedLat(String typeID, double speed){ 350 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_MAXSPEED_LAT, typeID, speed); 351 } 352 353 /** 354 * Sets the apparent deceleration in m/s^2 of vehicles of this type. 355 * @param typeID type id 356 * @param decel decel 357 * @return SumoCommand 358 */ setApparentDecel(String typeID, double decel)359 public static SumoCommand setApparentDecel(String typeID, double decel){ 360 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_APPARENT_DECEL, typeID, decel); 361 } 362 363 /** 364 * setImperfection 365 * @param typeID type id 366 * @param imperfection imperfection 367 * @return SumoCommand 368 */ setImperfection(String typeID, double imperfection)369 public static SumoCommand setImperfection(String typeID, double imperfection){ 370 371 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_IMPERFECTION, typeID, imperfection); 372 } 373 374 /** 375 * Sets the preferred lateral alignment of this type. 376 * @param typeID type id 377 * @param latAlignment latAlignment 378 * @return SumoCommand 379 */ setLateralAlignment(String typeID, String latAlignment)380 public static SumoCommand setLateralAlignment(String typeID, String latAlignment){ 381 382 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_LATALIGNMENT, typeID, latAlignment); 383 } 384 385 /** 386 * Sets the height in m of vehicles of this type. 387 * @param typeID type id 388 * @param height height 389 * @return SumoCommand 390 */ setHeight(String typeID, double height)391 public static SumoCommand setHeight(String typeID, double height){ 392 393 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_HEIGHT, typeID, height); 394 } 395 396 397 398 /** 399 * Sets the maximal physically possible deceleration in m/s^2 of vehicles of this type. 400 * @param typeID type id 401 * @param decel decel 402 * @return SumoCommand 403 */ setEmergencyDecel(String typeID, double decel)404 public static SumoCommand setEmergencyDecel(String typeID, double decel){ 405 406 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_EMERGENCY_DECEL, typeID, decel); 407 } 408 409 /** 410 * Sets the vehicle type's length to the given value. 411 * @param typeID type id 412 * @param length length 413 * @return SumoCommand 414 */ setLength(String typeID, double length)415 public static SumoCommand setLength(String typeID, double length){ 416 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_LENGTH, typeID, length); 417 } 418 419 /** 420 * Sets the vehicle type's maximum speed to the given value. 421 * @param typeID type id 422 * @param speed speed 423 * @return SumoCommand 424 */ 425 setMaxSpeed(String typeID, double speed)426 public static SumoCommand setMaxSpeed(String typeID, double speed){ 427 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_MAXSPEED, typeID, speed); 428 } 429 430 /** 431 * Sets the vehicle type's minimum headway gap to the given value. 432 * @param typeID type id 433 * @param minGap minimum gap 434 * @return SumoCommand 435 */ setMinGap(String typeID, double minGap)436 public static SumoCommand setMinGap(String typeID, double minGap){ 437 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_MINGAP, typeID, minGap); 438 } 439 440 /** 441 * setShapeClass 442 * @param typeID type id 443 * @param clazz shape class 444 * @return SumoCommand 445 */ setShapeClass(String typeID, String clazz)446 public static SumoCommand setShapeClass(String typeID, String clazz){ 447 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_SHAPECLASS, typeID, clazz); 448 } 449 450 /** 451 * Sets the vehicle type's speed deviation to the given value. 452 * @param typeID type id 453 * @param deviation deviation 454 * @return SumoCommand 455 */ setSpeedDeviation(String typeID, double deviation)456 public static SumoCommand setSpeedDeviation(String typeID, double deviation){ 457 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_SPEED_DEVIATION, typeID, deviation); 458 } 459 460 /** 461 * Sets the vehicle type's speed factor to the given value. 462 * @param typeID type id 463 * @param factor factor 464 * @return SumoCommand 465 */ setSpeedFactor(String typeID, double factor)466 public static SumoCommand setSpeedFactor(String typeID, double factor){ 467 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_SPEED_FACTOR, typeID, factor); 468 } 469 470 /** 471 * setTau 472 * @param typeID type id 473 * @param tau tau 474 * @return SumoCommand 475 */ setTau(String typeID, double tau)476 public static SumoCommand setTau(String typeID, double tau){ 477 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_TAU, typeID, tau); 478 } 479 480 /** 481 * Sets the vehicle type's vehicle class to the given value. 482 * @param typeID type id 483 * @param clazz vehicle class 484 * @return SumoCommand 485 */ setVehicleClass(String typeID, String clazz)486 public static SumoCommand setVehicleClass(String typeID, String clazz){ 487 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_VEHICLECLASS, typeID, clazz); 488 } 489 490 /** 491 * Sets the vehicle type's width to the given value. 492 * @param typeID type id 493 * @param width width 494 * @return SumoCommand 495 */ setWidth(String typeID, double width)496 public static SumoCommand setWidth(String typeID, double width){ 497 498 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.VAR_WIDTH, typeID, width); 499 } 500 501 /** 502 * Duplicates the vType with ID origTypeID. The newly created vType is assigned the ID newTypeID 503 * @param typeID type id 504 * @param newTypeID newTypeID 505 * @return SumoCommand 506 */ setWidth(String typeID, String newTypeID)507 public static SumoCommand setWidth(String typeID, String newTypeID){ 508 return new SumoCommand(Constants.CMD_SET_VEHICLETYPE_VARIABLE, Constants.COPY, typeID, newTypeID); 509 } 510 511 512 } 513