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 2001-2010 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/RGBColor.h>
00041 
00042 
00043 // ===========================================================================
00044 // class declarations
00045 // ===========================================================================
00046 class MSLane;
00047 class BinaryInputDevice;
00048 class MSCFModel;
00049 class SUMOVTypeParameter;
00050 
00051 
00052 // ===========================================================================
00053 // class definitions
00054 // ===========================================================================
00068 class MSVehicleType {
00069 public:
00087     MSVehicleType(const std::string &id, SUMOReal length, SUMOReal maxSpeed,
00088                   SUMOReal prob, SUMOReal speedFactor,
00089                   SUMOReal speedDev, SUMOVehicleClass vclass,
00090                   SUMOEmissionClass emissionClass, SUMOVehicleShape shape,
00091                   SUMOReal guiWidth, SUMOReal guiOffset,
00092                   int cfModel, const std::string &lcModel,
00093                   const RGBColor &c) throw();
00094 
00095 
00097     virtual ~MSVehicleType() throw();
00098 
00099 
00100 
00103 
00107     const std::string &getID() const throw() {
00108         return myID;
00109     }
00110 
00111 
00115     SUMOReal getLength() const throw() {
00116         return myLength;
00117     }
00118 
00119 
00123     inline const MSCFModel &getCarFollowModel() const throw() {
00124         return *myCarFollowModel;
00125     }
00126 
00127 
00131     SUMOReal getMaxSpeed() const throw() {
00132         return myMaxSpeed;
00133     }
00134 
00138     SUMOReal hasSpeedDeviation() const throw() {
00139         return mySpeedDev != 0.0 || mySpeedFactor != 1.0;
00140     }
00141 
00142 
00149     SUMOReal getMaxSpeedWithDeviation(SUMOReal referenceSpeed) const throw() {
00150         SUMOReal meanSpeed = mySpeedFactor * referenceSpeed;
00151         SUMOReal speedDev = mySpeedDev * meanSpeed;
00152         SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2*speedDev, myMaxSpeed);
00153         return MAX3((SUMOReal)0.0, speed, meanSpeed - 2*speedDev);
00154     }
00155 
00156 
00160     SUMOReal getDefaultProbability() const throw() {
00161         return myDefaultProbability;
00162     }
00163 
00164 
00169     SUMOVehicleClass getVehicleClass() const throw() {
00170         return myVehicleClass;
00171     }
00172 
00173 
00178     SUMOEmissionClass getEmissionClass() const throw() {
00179         return myEmissionClass;
00180     }
00181 
00182 
00186     const RGBColor &getColor() const throw() {
00187         return myColor;
00188     }
00190 
00191 
00192 
00195 
00200     SUMOVehicleShape getGuiShape() const throw() {
00201         return myShape;
00202     }
00203 
00204 
00208     SUMOReal getGuiWidth() const throw() {
00209         return myWidth;
00210     }
00211 
00212 
00216     SUMOReal getGuiOffset() const throw() {
00217         return myOffset;
00218     }
00220 
00221 
00222 
00223 
00224 
00226     void saveState(std::ostream &os);
00227 
00228 
00229 
00232 
00238     static MSVehicleType *build(SUMOVTypeParameter &from) throw(ProcessError);
00239 
00240 
00247     static SUMOReal get(const std::map<std::string, SUMOReal> &from, const std::string &name,
00248                         SUMOReal defaultValue) throw();
00250 
00251 
00252 private:
00254     std::string myID;
00255 
00257     SUMOReal myLength;
00258 
00260     SUMOReal myMaxSpeed;
00261 
00263     SUMOVehicleClass myVehicleClass;
00264 
00266     SUMOReal myDefaultProbability;
00267 
00269     SUMOReal mySpeedFactor;
00270 
00272     SUMOReal mySpeedDev;
00273 
00275     MSCFModel* myCarFollowModel;
00276 
00278     std::string myLaneChangeModel;
00279 
00281     SUMOEmissionClass myEmissionClass;
00282 
00284     RGBColor myColor;
00285 
00286 
00289 
00291     SUMOReal myWidth;
00292 
00294     SUMOReal myOffset;
00295 
00297     SUMOVehicleShape myShape;
00299 
00300 
00301 private:
00303     MSVehicleType(const MSVehicleType&);
00304 
00306     MSVehicleType& operator=(const MSVehicleType&);
00307 
00308 };
00309 
00310 
00311 #endif
00312 
00313 /****************************************************************************/
00314 

Generated on Wed May 5 00:06:32 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6