MSTriggeredRerouter.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSTriggeredRerouter_h
00020 #define MSTriggeredRerouter_h
00021
00022
00023
00024
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
00043
00044 class MSNet;
00045 class MSLane;
00046 class SUMOVehicle;
00047
00048
00049
00050
00051
00063 class MSTriggeredRerouter :
00064 public MSTrigger,
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 class Setter : public MSMoveReminder {
00088 public:
00094 Setter(MSTriggeredRerouter * const parent, MSLane * const lane) throw();
00095
00096
00098 ~Setter() throw();
00099
00100
00103
00118 bool isStillActive(MSVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
00119 SUMOReal newSpeed) throw();
00120
00121
00134 bool notifyEnter(MSVehicle& veh, bool isEmit, bool isLaneChange) throw();
00136
00137
00138 private:
00140 MSTriggeredRerouter * const myParent;
00141
00142 private:
00144 Setter(const Setter&);
00145
00147 Setter& operator=(const Setter&);
00148
00149
00150 };
00151
00156 struct RerouteInterval {
00158 SUMOTime begin;
00160 SUMOTime end;
00162 std::vector<MSEdge*> closed;
00164 RandomDistributor<MSEdge*> edgeProbs;
00166 RandomDistributor<const MSRoute*> routeProbs;
00167 };
00168
00170 void reroute(SUMOVehicle &veh, const MSEdge &src);
00171
00173 bool hasCurrentReroute(SUMOTime time, SUMOVehicle &veh) const;
00174
00176 const RerouteInterval &getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const;
00177
00179 bool hasCurrentReroute(SUMOTime time) const;
00180
00182 const RerouteInterval &getCurrentReroute(SUMOTime time) const;
00183
00185 void setUserMode(bool val);
00186
00188 void setUserUsageProbability(SUMOReal prob);
00189
00191 bool inUserMode() const;
00192
00194 SUMOReal getProbability() const;
00195
00197 SUMOReal getUserProbability() const;
00198
00199 protected:
00201
00202
00210 virtual void myStartElement(SumoXMLTag element,
00211 const SUMOSAXAttributes &attrs) throw(ProcessError);
00212
00213
00220 void myEndElement(SumoXMLTag element) throw(ProcessError);
00222
00223 protected:
00225 std::vector<Setter*> mySetter;
00226
00228 std::vector<RerouteInterval> myIntervals;
00229
00231 SUMOReal myProbability, myUserProbability;
00232
00234 bool myAmInUserMode;
00235
00237
00238
00240 SUMOTime myCurrentIntervalBegin, myCurrentIntervalEnd;
00242 std::vector<MSEdge*> myCurrentClosed;
00244 RandomDistributor<MSEdge*> myCurrentEdgeProb;
00246 RandomDistributor<const MSRoute*> myCurrentRouteProb;
00248
00249 private:
00251 MSTriggeredRerouter(const MSTriggeredRerouter&);
00252
00254 MSTriggeredRerouter& operator=(const MSTriggeredRerouter&);
00255
00256
00257 };
00258
00259
00260 #endif
00261
00262
00263