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 MSRoute;
00050 class SUMOVehicle;
00051 
00052 
00053 // ===========================================================================
00054 // class definitions
00055 // ===========================================================================
00067 class MSTriggeredRerouter :
00068     public MSTrigger, public MSMoveReminder,
00069     public SUMOSAXHandler {
00070 public:
00078     MSTriggeredRerouter(const std::string& id,
00079                         const std::vector<MSEdge*> &edges,
00080                         SUMOReal prob, const std::string& file, bool off);
00081 
00082 
00084     virtual ~MSTriggeredRerouter() ;
00085 
00086 
00091     struct RerouteInterval {
00093         SUMOTime begin;
00095         SUMOTime end;
00097         std::vector<MSEdge*> closed;
00099         RandomDistributor<MSEdge*> edgeProbs;
00101         RandomDistributor<const MSRoute*> routeProbs;
00102     };
00103 
00118     bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) ;
00119 
00121     bool hasCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
00122 
00124     const RerouteInterval& getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
00125 
00127     bool hasCurrentReroute(SUMOTime time) const;
00128 
00130     const RerouteInterval& getCurrentReroute(SUMOTime time) const;
00131 
00133     void setUserMode(bool val);
00134 
00136     void setUserUsageProbability(SUMOReal prob);
00137 
00139     bool inUserMode() const;
00140 
00142     SUMOReal getProbability() const;
00143 
00145     SUMOReal getUserProbability() const;
00146 
00147 protected:
00149 
00150 
00158     virtual void myStartElement(int element,
00159                                 const SUMOSAXAttributes& attrs) ;
00160 
00161 
00168     void myEndElement(int element) ;
00170 
00171 protected:
00173     std::vector<RerouteInterval> myIntervals;
00174 
00176     SUMOReal myProbability, myUserProbability;
00177 
00179     bool myAmInUserMode;
00180 
00182 
00183 
00185     SUMOTime myCurrentIntervalBegin, myCurrentIntervalEnd;
00187     std::vector<MSEdge*> myCurrentClosed;
00189     RandomDistributor<MSEdge*> myCurrentEdgeProb;
00191     RandomDistributor<const MSRoute*> myCurrentRouteProb;
00193 
00194     static bool myHaveWarnedAboutDeprecatedDestProbReroute,
00195            myHaveWarnedAboutDeprecatedClosingReroute,
00196            myHaveWarnedAboutDeprecatedRouteReroute;
00197 
00198 private:
00200     MSTriggeredRerouter(const MSTriggeredRerouter&);
00201 
00203     MSTriggeredRerouter& operator=(const MSTriggeredRerouter&);
00204 
00205 
00206 };
00207 
00208 
00209 #endif
00210 
00211 /****************************************************************************/
00212 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines