|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Class for loading trip amount definitions and route generation 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 RORDGenerator_ODAmounts_h 00020 #define RORDGenerator_ODAmounts_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 <set> 00034 #include <utils/options/OptionsCont.h> 00035 #include <utils/common/IDSupplier.h> 00036 #include <utils/xml/SUMOXMLDefinitions.h> 00037 #include "RORDLoader_TripDefs.h" 00038 #include "RONet.h" 00039 #include <utils/common/SUMOTime.h> 00040 00041 00042 // =========================================================================== 00043 // class definitions 00044 // =========================================================================== 00051 class RORDGenerator_ODAmounts : public RORDLoader_TripDefs { 00052 public: 00054 RORDGenerator_ODAmounts(RONet& net, 00055 SUMOTime begin, SUMOTime end, bool emptyDestinationsAllowed, 00056 bool randomize, const std::string& file="") throw(ProcessError); 00057 00059 ~RORDGenerator_ODAmounts() throw(); 00060 00061 00063 00064 00073 bool readRoutesAtLeastUntil(SUMOTime until, bool skipping) throw(ProcessError); 00075 00076 00077 protected: 00079 00080 00088 void myStartElement(int element, 00089 const SUMOSAXAttributes& attrs) throw(ProcessError); 00090 00091 00098 void myEndElement(int element) throw(ProcessError); 00100 00102 void parseInterval(const SUMOSAXAttributes& attrs); 00103 00105 void parseFlowAmountDef(const SUMOSAXAttributes& attrs) throw(ProcessError); 00106 00108 void myEndInterval(); 00109 00111 void myEndFlowAmountDef(); 00112 00117 class FlowDef { 00118 public: 00120 FlowDef(ROVehicle* vehicle, SUMOVTypeParameter* type, RORouteDef* route, 00121 SUMOTime intBegin, SUMOTime intEnd, 00122 unsigned int vehicles2insert, bool randomize); 00123 00125 ~FlowDef(); 00126 00128 bool applicableForTime(SUMOTime time) const; 00129 00131 void addRoutes(RONet& net, SUMOTime time); 00132 00134 void addSingleRoute(RONet& net, SUMOTime time); 00135 00137 SUMOTime getIntervalEnd() const; 00138 00139 private: 00141 ROVehicle* myVehicle; 00142 00144 SUMOVTypeParameter* myVehicleType; 00145 00147 RORouteDef* myRoute; 00148 00150 SUMOTime myIntervalBegin; 00151 00153 SUMOTime myIntervalEnd; 00154 00156 unsigned int myVehicle2InsertNumber; 00157 00159 unsigned int myInserted; 00160 00162 std::vector<SUMOTime> myDepartures; 00163 00165 bool myRandom; 00166 00167 }; 00168 00169 private: 00171 void buildRoutes(SUMOTime until) throw(); 00172 00174 void buildForTimeStep(SUMOTime time) throw(); 00175 00176 private: 00178 SUMOTime myIntervalBegin; 00179 00181 SUMOTime myIntervalEnd; 00182 00184 SUMOTime myUpperIntervalBegin; 00185 00187 SUMOTime myUpperIntervalEnd; 00188 00190 unsigned int myVehicle2InsertNumber; 00191 00193 SUMOTime myCurrentTimeStep; 00194 00196 typedef std::vector<FlowDef*> FlowDefV; 00197 00199 FlowDefV myFlows; 00200 00202 std::set<std::string> myKnownIDs; 00203 00205 bool myRandom; 00206 00207 00208 bool myHaveWarnedAboutDeprecatedNumber; 00209 00210 private: 00212 RORDGenerator_ODAmounts(const RORDGenerator_ODAmounts& src); 00213 00215 RORDGenerator_ODAmounts& operator=(const RORDGenerator_ODAmounts& src); 00216 00217 }; 00218 00219 00220 #endif 00221 00222 /****************************************************************************/ 00223