|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A device which collects info on the vehicle trip 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 MSDevice_Vehroutes_h 00020 #define MSDevice_Vehroutes_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 "MSDevice.h" 00033 #include <microsim/MSNet.h> 00034 #include <utils/common/SUMOTime.h> 00035 00036 00037 // =========================================================================== 00038 // class declarations 00039 // =========================================================================== 00040 class MSEdge; 00041 class MSRoute; 00042 00043 00044 // =========================================================================== 00045 // class definitions 00046 // =========================================================================== 00055 class MSDevice_Vehroutes : public MSDevice { 00056 public: 00059 static void init() throw(IOError); 00060 00061 00072 static MSDevice_Vehroutes* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*> &into, unsigned int maxRoutes=INT_MAX) throw(); 00073 00074 00075 public: 00078 00087 bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) throw(); 00088 00089 00101 bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason) throw(); 00103 00104 00111 void generateOutput() const throw(IOError); 00112 00113 00119 const MSRoute* getRoute(int index) const; 00120 00121 00123 ~MSDevice_Vehroutes() throw(); 00124 00125 00126 private: 00132 MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, unsigned int maxRoutes) throw(); 00133 00134 00140 void writeXMLRoute(OutputDevice& os, int index=-1) const; 00141 00142 00145 void addRoute(); 00146 00147 00148 private: 00150 static bool mySaveExits; 00151 00153 static bool myLastRouteOnly; 00154 00156 static bool mySorted; 00157 00159 static bool myWithTaz; 00160 00161 class StateListener : public MSNet::VehicleStateListener { 00162 public: 00164 ~StateListener() {} 00165 00170 void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to); 00171 00173 std::map<const SUMOVehicle*, MSDevice_Vehroutes*> myDevices; 00174 }; 00175 00176 static StateListener myStateListener; 00177 00178 static std::map<const SUMOTime, int> myDepartureCounts; 00179 00180 static std::map<const SUMOTime, std::string> myRouteInfos; 00181 00191 class RouteReplaceInfo { 00192 public: 00194 RouteReplaceInfo(const MSEdge* const edge_, const SUMOTime time_, const MSRoute* const route_) 00195 : edge(edge_), time(time_), route(route_) {} 00196 00198 ~RouteReplaceInfo() { } 00199 00201 const MSEdge* edge; 00202 00204 SUMOTime time; 00205 00207 const MSRoute* route; 00208 00209 }; 00210 00211 const MSRoute* myCurrentRoute; 00212 std::vector<RouteReplaceInfo> myReplacedRoutes; 00213 std::vector<SUMOTime> myExits; 00214 const unsigned int myMaxRoutes; 00215 const MSEdge* myLastSavedAt; 00216 00217 private: 00219 MSDevice_Vehroutes(const MSDevice_Vehroutes&); 00220 00222 MSDevice_Vehroutes& operator=(const MSDevice_Vehroutes&); 00223 00224 00225 }; 00226 00227 00228 #endif 00229 00230 /****************************************************************************/ 00231