SUMO - Simulation of Urban MObility

MSTriggeredRerouter.h

Go to the documentation of this file.
00001 /****************************************************************************/
00009 // Reroutes vehicles passing an edge
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef MSTriggeredRerouter_h
00023 #define MSTriggeredRerouter_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <string>
00036 #include <vector>
00037 #include <utils/common/Command.h>
00038 #include <microsim/MSMoveReminder.h>
00039 #include "MSTrigger.h"
00040 #include <utils/xml/SUMOSAXHandler.h>
00041 #include <utils/common/RandomDistributor.h>
00042 
00043 
00044 // ===========================================================================
00045 // class declarations
00046 // ===========================================================================
00047 class MSNet;
00048 class MSLane;
00049 class SUMOVehicle;
00050 
00051 
00052 // ===========================================================================
00053 // class definitions
00054 // ===========================================================================
00066 class MSTriggeredRerouter :
00067     public MSTrigger, public MSMoveReminder,
00068     public SUMOSAXHandler {
00069 public:
00077     MSTriggeredRerouter(const std::string& id,
00078                         const std::vector<MSEdge*> &edges,
00079                         SUMOReal prob, const std::string& file, bool off);
00080 
00081 
00083     virtual ~MSTriggeredRerouter() ;
00084 
00085 
00090     struct RerouteInterval {
00092         SUMOTime begin;
00094         SUMOTime end;
00096         std::vector<MSEdge*> closed;
00098         RandomDistributor<MSEdge*> edgeProbs;
00100         RandomDistributor<const MSRoute*> routeProbs;
00101     };
00102 
00117     bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) ;
00118 
00120     bool hasCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
00121 
00123     const RerouteInterval& getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
00124 
00126     bool hasCurrentReroute(SUMOTime time) const;
00127 
00129     const RerouteInterval& getCurrentReroute(SUMOTime time) const;
00130 
00132     void setUserMode(bool val);
00133 
00135     void setUserUsageProbability(SUMOReal prob);
00136 
00138     bool inUserMode() const;
00139 
00141     SUMOReal getProbability() const;
00142 
00144     SUMOReal getUserProbability() const;
00145 
00146 protected:
00148 
00149 
00157     virtual void myStartElement(int element,
00158                                 const SUMOSAXAttributes& attrs) ;
00159 
00160 
00167     void myEndElement(int element) ;
00169 
00170 protected:
00172     std::vector<RerouteInterval> myIntervals;
00173 
00175     SUMOReal myProbability, myUserProbability;
00176 
00178     bool myAmInUserMode;
00179 
00181 
00182 
00184     SUMOTime myCurrentIntervalBegin, myCurrentIntervalEnd;
00186     std::vector<MSEdge*> myCurrentClosed;
00188     RandomDistributor<MSEdge*> myCurrentEdgeProb;
00190     RandomDistributor<const MSRoute*> myCurrentRouteProb;
00192 
00193     static bool myHaveWarnedAboutDeprecatedDestProbReroute,
00194            myHaveWarnedAboutDeprecatedClosingReroute,
00195            myHaveWarnedAboutDeprecatedRouteReroute;
00196 
00197 private:
00199     MSTriggeredRerouter(const MSTriggeredRerouter&);
00200 
00202     MSTriggeredRerouter& operator=(const MSTriggeredRerouter&);
00203 
00204 
00205 };
00206 
00207 
00208 #endif
00209 
00210 /****************************************************************************/
00211 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines