|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A base class for vehicle implementations 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 MSBaseVehicle_h 00020 #define MSBaseVehicle_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 <iostream> 00033 #include <cassert> 00034 #include <vector> 00035 #include <utils/common/SUMOVehicle.h> 00036 #include <utils/common/StdDefs.h> 00037 #include "MSRoute.h" 00038 #include "MSMoveReminder.h" 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class SUMOVehicleParameter; 00045 class MSVehicleType; 00046 00047 00048 // =========================================================================== 00049 // class definitions 00050 // =========================================================================== 00055 class MSBaseVehicle : public SUMOVehicle { 00056 public: 00059 MSBaseVehicle(SUMOVehicleParameter* pars, const MSRoute* route, const MSVehicleType* type) throw(ProcessError); 00060 00061 00063 virtual ~MSBaseVehicle() throw(); 00064 00065 00067 const std::string& getID() const throw(); 00068 00073 const SUMOVehicleParameter& getParameter() const throw(); 00074 00075 00079 const MSRoute& getRoute() const throw(); 00080 00081 00085 const MSVehicleType& getVehicleType() const throw(); 00086 00087 00091 SUMOReal getMaxSpeed() const; 00092 00093 00097 SUMOReal adaptMaxSpeed(SUMOReal referenceSpeed); 00098 00099 00107 const MSEdge* succEdge(unsigned int nSuccs) const throw(); 00108 00113 const MSEdge* getEdge() const; 00114 00115 00119 virtual bool isOnRoad() const throw() { 00120 return true; 00121 } 00122 00123 00133 void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle> &router, bool withTaz=false) throw(); 00134 00135 00146 bool replaceRouteEdges(const MSEdgeVector& edges, bool onInit=false) throw(); 00147 00148 00155 virtual SUMOReal getPreDawdleAcceleration() const throw(); 00156 00162 void onDepart() throw(); 00163 00167 SUMOTime getDeparture() const throw(); 00168 00172 unsigned int getNumberReroutes() const throw(); 00173 00177 const std::vector<MSDevice*> &getDevices() const { 00178 return myDevices; 00179 } 00180 00187 virtual void addPerson(MSPerson* person) throw(); 00188 00192 virtual bool isStopped() const; 00193 00198 bool hasValidRoute(std::string& msg) const throw(); 00199 00205 void addReminder(MSMoveReminder* rem) throw(); 00206 00212 void removeReminder(MSMoveReminder* rem) throw(); 00213 00224 virtual void activateReminders(const MSMoveReminder::Notification reason) throw(); 00225 00226 protected: 00229 void calculateArrivalPos() throw(); 00230 00231 protected: 00233 const SUMOVehicleParameter* myParameter; 00234 00236 const MSRoute* myRoute; 00237 00239 const MSVehicleType* myType; 00240 00242 MSRouteIterator myCurrEdge; 00243 00248 SUMOReal myIndividualMaxSpeed; 00249 00251 bool myHasIndividualMaxSpeed; 00252 00254 SUMOReal myReferenceSpeed; 00255 00258 00260 typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MoveReminderCont; 00261 00263 MoveReminderCont myMoveReminders; 00265 00267 std::vector<MSDevice*> myDevices; 00268 00270 SUMOTime myDeparture; 00271 00273 SUMOReal myArrivalPos; 00274 00276 unsigned int myNumberReroutes; 00277 00278 }; 00279 00280 #endif 00281 00282 /****************************************************************************/