|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Reroutes vehicles passing an edge 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 MSTriggeredRerouter_h 00020 #define MSTriggeredRerouter_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 <string> 00033 #include <vector> 00034 #include <utils/common/Command.h> 00035 #include <microsim/MSMoveReminder.h> 00036 #include "MSTrigger.h" 00037 #include <utils/xml/SUMOSAXHandler.h> 00038 #include <utils/common/RandomDistributor.h> 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class MSNet; 00045 class MSLane; 00046 class SUMOVehicle; 00047 00048 00049 // =========================================================================== 00050 // class definitions 00051 // =========================================================================== 00063 class MSTriggeredRerouter : 00064 public MSTrigger, public MSMoveReminder, 00065 public SUMOSAXHandler { 00066 public: 00074 MSTriggeredRerouter(const std::string& id, 00075 const std::vector<MSEdge*> &edges, 00076 SUMOReal prob, const std::string& file, bool off); 00077 00078 00080 virtual ~MSTriggeredRerouter() throw(); 00081 00082 00087 struct RerouteInterval { 00089 SUMOTime begin; 00091 SUMOTime end; 00093 std::vector<MSEdge*> closed; 00095 RandomDistributor<MSEdge*> edgeProbs; 00097 RandomDistributor<const MSRoute*> routeProbs; 00098 }; 00099 00114 bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) throw(); 00115 00117 bool hasCurrentReroute(SUMOTime time, SUMOVehicle& veh) const; 00118 00120 const RerouteInterval& getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const; 00121 00123 bool hasCurrentReroute(SUMOTime time) const; 00124 00126 const RerouteInterval& getCurrentReroute(SUMOTime time) const; 00127 00129 void setUserMode(bool val); 00130 00132 void setUserUsageProbability(SUMOReal prob); 00133 00135 bool inUserMode() const; 00136 00138 SUMOReal getProbability() const; 00139 00141 SUMOReal getUserProbability() const; 00142 00143 protected: 00145 00146 00154 virtual void myStartElement(int element, 00155 const SUMOSAXAttributes& attrs) throw(ProcessError); 00156 00157 00164 void myEndElement(int element) throw(ProcessError); 00166 00167 protected: 00169 std::vector<RerouteInterval> myIntervals; 00170 00172 SUMOReal myProbability, myUserProbability; 00173 00175 bool myAmInUserMode; 00176 00178 00179 00181 SUMOTime myCurrentIntervalBegin, myCurrentIntervalEnd; 00183 std::vector<MSEdge*> myCurrentClosed; 00185 RandomDistributor<MSEdge*> myCurrentEdgeProb; 00187 RandomDistributor<const MSRoute*> myCurrentRouteProb; 00189 00190 static bool myHaveWarnedAboutDeprecatedDestProbReroute, 00191 myHaveWarnedAboutDeprecatedClosingReroute, 00192 myHaveWarnedAboutDeprecatedRouteReroute; 00193 00194 private: 00196 MSTriggeredRerouter(const MSTriggeredRerouter&); 00197 00199 MSTriggeredRerouter& operator=(const MSTriggeredRerouter&); 00200 00201 00202 }; 00203 00204 00205 #endif 00206 00207 /****************************************************************************/ 00208