SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSVehicleType.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The car-following model and parameter
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSVehicleType_h
24 #define MSVehicleType_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <cassert>
37 #include <map>
38 #include <string>
39 #include "MSCFModel.h"
40 #include <utils/common/SUMOTime.h>
41 #include <utils/common/StdDefs.h>
45 #include <utils/common/RGBColor.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSLane;
52 class BinaryInputDevice;
53 class MSCFModel;
54 class SUMOVTypeParameter;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
74 public:
93  MSVehicleType(const std::string& id, const SUMOReal lengthWithGap,
94  const SUMOReal minGap, const SUMOReal maxSpeed,
95  const SUMOReal prob, const SUMOReal speedFactor,
96  const SUMOReal speedDev, const SUMOVehicleClass vclass,
97  const SUMOEmissionClass emissionClass,
98  const SUMOReal width, const SUMOReal height,
99  const SUMOVehicleShape shape, const std::string osgFile,
100  const std::string& lcModel,
101  const RGBColor& c) ;
102 
103 
105  virtual ~MSVehicleType() ;
106 
107 
108 
111 
115  const std::string& getID() const {
116  return myID;
117  }
118 
119 
123  SUMOReal getLength() const {
124  return myLength;
125  }
126 
127 
132  return myLength + myMinGap;
133  }
134 
135 
139  SUMOReal getMinGap() const {
140  return myMinGap;
141  }
142 
143 
147  inline const MSCFModel& getCarFollowModel() const {
148  return *myCarFollowModel;
149  }
150 
151 
156  return *myCarFollowModel;
157  }
158 
159 
164  return myMaxSpeed;
165  }
166 
171  return mySpeedDev != 0.0 || mySpeedFactor != 1.0;
172  }
173 
174 
182  SUMOReal meanSpeed = mySpeedFactor * referenceSpeed;
183  SUMOReal speedDev = mySpeedDev * meanSpeed;
184  SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2 * speedDev, myMaxSpeed);
185  return MAX3((SUMOReal)0.0, speed, meanSpeed - 2 * speedDev);
186  }
187 
188 
193  return myDefaultProbability;
194  }
195 
196 
202  return myVehicleClass;
203  }
204 
205 
211  return myEmissionClass;
212  }
213 
214 
218  const RGBColor& getColor() const {
219  return myColor;
220  }
221 
222 
227  return mySpeedFactor;
228  }
229 
230 
235  return mySpeedDev;
236  }
238 
239 
240 
243 
247  SUMOReal getWidth() const {
248  return myWidth;
249  }
250 
254  SUMOReal getHeight() const {
255  return myHeight;
256  }
257 
263  return myShape;
264  }
265 
269  std::string getOSGFile() const {
270  return myOSGFile;
271  }
272 
274 
275 
276 
277 
278 
280  void saveState(std::ostream& os);
281 
282 
283 
286 
294  void setLength(const SUMOReal& length) ;
295 
296 
304  void setMinGap(const SUMOReal& minGap) ;
305 
306 
314  void setMaxSpeed(const SUMOReal& maxSpeed) ;
315 
316 
320  void setVClass(SUMOVehicleClass vclass) ;
321 
322 
330  void setDefaultProbability(const SUMOReal& prob) ;
331 
332 
340  void setSpeedFactor(const SUMOReal& factor) ;
341 
342 
350  void setSpeedDeviation(const SUMOReal& dev) ;
351 
352 
356  void setEmissionClass(SUMOEmissionClass eclass) ;
357 
358 
362  void setColor(const RGBColor& color) ;
363 
364 
372  void setWidth(const SUMOReal& width) ;
373 
374 
378  void setShape(SUMOVehicleShape shape) ;
380 
381 
382 
385 
391  static MSVehicleType* build(SUMOVTypeParameter& from) ;
392 
393 
399  static MSVehicleType* build(const std::string& id, const MSVehicleType* from) ;
401 
402 
406  bool amVehicleSpecific() const {
407  return myOriginalType != 0;
408  }
409 
410 
411 private:
413  std::string myID;
414 
417 
420 
423 
426 
429 
432 
435 
437  std::string myLaneChangeModel;
438 
441 
444 
447 
448 
451 
454 
457 
460 
462  std::string myOSGFile;
464 
465 
468 
469 
470 private:
473 
476 
477 };
478 
479 
480 #endif
481 
482 /****************************************************************************/
483