SUMO - Simulation of Urban MObility

MSVehicleType.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The car-following model and parameter
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef MSVehicleType_h
00020 #define MSVehicleType_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <cassert>
00033 #include <map>
00034 #include <string>
00035 #include "MSCFModel.h"
00036 #include <utils/common/SUMOTime.h>
00037 #include <utils/common/StdDefs.h>
00038 #include <utils/common/SUMOVehicleClass.h>
00039 #include <utils/common/RandHelper.h>
00040 #include <utils/common/SUMOVTypeParameter.h>
00041 #include <utils/common/RGBColor.h>
00042 
00043 
00044 // ===========================================================================
00045 // class declarations
00046 // ===========================================================================
00047 class MSLane;
00048 class BinaryInputDevice;
00049 class MSCFModel;
00050 class SUMOVTypeParameter;
00051 
00052 
00053 // ===========================================================================
00054 // class definitions
00055 // ===========================================================================
00069 class MSVehicleType {
00070 public:
00087     MSVehicleType(const std::string& id, SUMOReal lengthWithGap,
00088                   SUMOReal minGap, SUMOReal maxSpeed,
00089                   SUMOReal prob, SUMOReal speedFactor,
00090                   SUMOReal speedDev, SUMOVehicleClass vclass,
00091                   SUMOEmissionClass emissionClass,
00092                   SUMOReal guiWidth, SUMOVehicleShape shape,
00093                   const std::string& lcModel,
00094                   const RGBColor& c) throw();
00095 
00096 
00098     virtual ~MSVehicleType() throw();
00099 
00100 
00101 
00104 
00108     const std::string& getID() const throw() {
00109         return myID;
00110     }
00111 
00112 
00116     SUMOReal getLength() const throw() {
00117         return myLength;
00118     }
00119 
00120 
00124     SUMOReal getLengthWithGap() const throw() {
00125         return myLength + myMinGap;
00126     }
00127 
00128 
00132     SUMOReal getMinGap() const throw() {
00133         return myMinGap;
00134     }
00135 
00136 
00140     inline const MSCFModel& getCarFollowModel() const throw() {
00141         return *myCarFollowModel;
00142     }
00143 
00144 
00148     inline MSCFModel& getCarFollowModel() throw() {
00149         return *myCarFollowModel;
00150     }
00151 
00152 
00156     SUMOReal getMaxSpeed() const throw() {
00157         return myMaxSpeed;
00158     }
00159 
00163     SUMOReal hasSpeedDeviation() const throw() {
00164         return mySpeedDev != 0.0 || mySpeedFactor != 1.0;
00165     }
00166 
00167 
00174     SUMOReal getMaxSpeedWithDeviation(SUMOReal referenceSpeed) const throw() {
00175         SUMOReal meanSpeed = mySpeedFactor * referenceSpeed;
00176         SUMOReal speedDev = mySpeedDev * meanSpeed;
00177         SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2*speedDev, myMaxSpeed);
00178         return MAX3((SUMOReal)0.0, speed, meanSpeed - 2*speedDev);
00179     }
00180 
00181 
00185     SUMOReal getDefaultProbability() const throw() {
00186         return myDefaultProbability;
00187     }
00188 
00189 
00194     SUMOVehicleClass getVehicleClass() const throw() {
00195         return myVehicleClass;
00196     }
00197 
00198 
00203     SUMOEmissionClass getEmissionClass() const throw() {
00204         return myEmissionClass;
00205     }
00206 
00207 
00211     const RGBColor& getColor() const throw() {
00212         return myColor;
00213     }
00214 
00215 
00219     SUMOReal getSpeedFactor() const throw() {
00220         return mySpeedFactor;
00221     }
00222 
00223 
00227     SUMOReal getSpeedDeviation() const throw() {
00228         return mySpeedDev;
00229     }
00231 
00232 
00233 
00236 
00240     SUMOReal getGuiWidth() const throw() {
00241         return myWidth;
00242     }
00243 
00248     SUMOVehicleShape getGuiShape() const throw() {
00249         return myShape;
00250     }
00251 
00253 
00254 
00255 
00256 
00257 
00259     void saveState(std::ostream& os);
00260 
00261 
00262 
00265 
00273     void setLength(const SUMOReal& length) throw();
00274 
00275 
00283     void setMinGap(const SUMOReal& minGap) throw();
00284 
00285 
00293     void setMaxSpeed(const SUMOReal& maxSpeed) throw();
00294 
00295 
00299     void setVClass(SUMOVehicleClass vclass) throw();
00300 
00301 
00309     void setDefaultProbability(const SUMOReal& prob) throw();
00310 
00311 
00319     void setSpeedFactor(const SUMOReal& factor) throw();
00320 
00321 
00329     void setSpeedDeviation(const SUMOReal& dev) throw();
00330 
00331 
00335     void setEmissionClass(SUMOEmissionClass eclass) throw();
00336 
00337 
00341     void setColor(const RGBColor& color) throw();
00342 
00343 
00351     void setWidth(const SUMOReal& width) throw();
00352 
00353 
00357     void setShape(SUMOVehicleShape shape) throw();
00359 
00360 
00361 
00364 
00370     static MSVehicleType* build(SUMOVTypeParameter& from) throw(ProcessError);
00371 
00372 
00378     static MSVehicleType* build(const std::string& id, const MSVehicleType* from) throw();
00379 
00380 
00387     static SUMOReal get(const SUMOVTypeParameter::CFParams& from, SumoXMLAttr attr, SUMOReal defaultValue);
00389 
00390 
00394     bool amVehicleSpecific() const throw() {
00395         return myOriginalType!=0;
00396     }
00397 
00398 
00399 private:
00401     std::string myID;
00402 
00404     SUMOReal myLength;
00405 
00407     SUMOReal myMinGap;
00408 
00410     SUMOReal myMaxSpeed;
00411 
00413     SUMOReal myDefaultProbability;
00414 
00416     SUMOReal mySpeedFactor;
00417 
00419     SUMOReal mySpeedDev;
00420 
00422     MSCFModel* myCarFollowModel;
00423 
00425     std::string myLaneChangeModel;
00426 
00428     SUMOEmissionClass myEmissionClass;
00429 
00431     RGBColor myColor;
00432 
00434     SUMOVehicleClass myVehicleClass;
00435 
00436 
00439 
00441     SUMOReal myWidth;
00442 
00444     SUMOVehicleShape myShape;
00446 
00447 
00449     const MSVehicleType* myOriginalType;
00450 
00451 
00452 private:
00454     MSVehicleType(const MSVehicleType&);
00455 
00457     MSVehicleType& operator=(const MSVehicleType&);
00458 
00459 };
00460 
00461 
00462 #endif
00463 
00464 /****************************************************************************/
00465 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines