SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // The XML-Handler for network loading 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef NLHandler_h 00024 #define NLHandler_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <xercesc/sax/HandlerBase.hpp> 00037 #include <xercesc/sax/SAXException.hpp> 00038 #include <xercesc/sax/AttributeList.hpp> 00039 #include <utils/common/SUMOTime.h> 00040 #include <utils/xml/SUMOXMLDefinitions.h> 00041 #include <microsim/MSLink.h> 00042 #include <microsim/MSRouteHandler.h> 00043 #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h> 00044 #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h> 00045 #include <microsim/MSBitSetLogic.h> 00046 #include "NLBuilder.h" 00047 #include "NLDiscreteEventBuilder.h" 00048 #include "NLSucceedingLaneBuilder.h" 00049 00050 00051 // =========================================================================== 00052 // class declarations 00053 // =========================================================================== 00054 class NLContainer; 00055 class NLDetectorBuilder; 00056 class NLTriggerBuilder; 00057 class MSTrafficLightLogic; 00058 00059 00060 // =========================================================================== 00061 // class definitions 00062 // =========================================================================== 00071 class NLHandler : public MSRouteHandler { 00072 public: 00074 typedef std::vector<MSLane*> LaneVector; 00075 00076 public: 00086 NLHandler(const std::string& file, MSNet& net, 00087 NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder, 00088 NLEdgeControlBuilder& edgeBuilder, 00089 NLJunctionControlBuilder& junctionBuilder) ; 00090 00091 00093 virtual ~NLHandler() ; 00094 00095 00096 protected: 00098 00099 00108 virtual void myStartElement(int element, 00109 const SUMOSAXAttributes& attrs) ; 00110 00111 00119 virtual void myEndElement(int element) ; 00121 00122 00123 protected: 00124 void addParam(const SUMOSAXAttributes& attrs); 00125 00129 virtual void addE1Detector(const SUMOSAXAttributes& attrs); 00130 00134 virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs); 00135 00139 virtual void addE2Detector(const SUMOSAXAttributes& attrs); 00140 00144 void beginE3Detector(const SUMOSAXAttributes& attrs); 00145 00149 void addE3Entry(const SUMOSAXAttributes& attrs); 00150 00154 void addE3Exit(const SUMOSAXAttributes& attrs); 00155 00157 virtual void endE3Detector(); 00158 00162 virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs); 00163 00167 virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs); 00168 00173 virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype); 00174 00176 virtual void closeEdge(); 00177 00178 00179 protected: 00181 MSNet& myNet; 00182 00183 00184 private: 00186 void beginEdgeParsing(const SUMOSAXAttributes& attrs); 00187 00189 void addLane(const SUMOSAXAttributes& attrs); 00190 00192 void addPOI(const SUMOSAXAttributes& attrs); 00193 00195 void addPoly(const SUMOSAXAttributes& attrs); 00196 00198 void addLogicItem(const SUMOSAXAttributes& attrs); 00199 00201 void addRequest(const SUMOSAXAttributes& attrs); 00202 00204 void initJunctionLogic(const SUMOSAXAttributes& attrs); 00205 00207 void initTrafficLightLogic(const SUMOSAXAttributes& attrs); 00208 00210 void addPhase(const SUMOSAXAttributes& attrs); 00211 00212 00214 virtual void openJunction(const SUMOSAXAttributes& attrs); 00215 00216 void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*> &into, bool& ok); 00217 00218 #ifdef _MESSAGES 00219 00220 void addMsgEmitter(const SUMOSAXAttributes& attrs); 00221 #endif 00222 00224 void openSucc(const SUMOSAXAttributes& attrs); 00225 00227 void addSuccLane(const SUMOSAXAttributes& attrs); 00228 00230 void addConnection(const SUMOSAXAttributes& attrs); 00231 00232 virtual void openWAUT(const SUMOSAXAttributes& attrs); 00233 void addWAUTSwitch(const SUMOSAXAttributes& attrs); 00234 void addWAUTJunction(const SUMOSAXAttributes& attrs); 00235 00237 void setLocation(const SUMOSAXAttributes& attrs); 00238 00248 void addDistrict(const SUMOSAXAttributes& attrs) ; 00249 00250 00261 void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource); 00262 00263 00264 void closeWAUT(); 00265 00267 void closeSuccLane(); 00268 00270 LinkDirection parseLinkDir(const std::string& dir); 00271 00273 LinkState parseLinkState(const std::string& state); 00274 00276 std::pair<MSLane*, MSLane*> getLanesFromIndices(MSEdge* from, MSEdge* to, const std::string& laneIndices, bool& ok); 00277 00278 00279 protected: 00281 NLDiscreteEventBuilder myActionBuilder; 00282 00284 bool myCurrentIsInternalToSkip; 00285 00286 00288 NLDetectorBuilder& myDetectorBuilder; 00289 00291 NLTriggerBuilder& myTriggerBuilder; 00292 00294 NLEdgeControlBuilder& myEdgeControlBuilder; 00295 00297 NLJunctionControlBuilder& myJunctionControlBuilder; 00298 00300 NLSucceedingLaneBuilder mySucceedingLaneBuilder; 00301 00302 00303 00305 std::string myCurrentDistrictID; 00306 00308 bool myAmInTLLogicMode; 00309 00311 std::string myCurrentWAUTID; 00312 00314 Position myNetworkOffset; 00315 00317 Boundary myOrigBoundary, myConvBoundary; 00318 00319 bool myCurrentIsBroken; 00320 00321 bool myHaveWarnedAboutDeprecatedE1, myHaveWarnedAboutDeprecatedE2, 00322 myHaveWarnedAboutDeprecatedE3, myHaveWarnedAboutDeprecatedDetEntry, 00323 myHaveWarnedAboutDeprecatedDetExit, myHaveWarnedAboutDeprecatedTimedEvent; 00324 bool myHaveWarnedAboutDeprecatedRowLogic, myHaveWarnedAboutDeprecatedTLLogic; 00325 bool myHaveWarnedAboutDeprecatedTLSTiming; 00326 bool myHaveWarnedAboutDeprecatedTimeThreshold, 00327 myHaveWarnedAboutDeprecatedSpeedThreshold, 00328 myHaveWarnedAboutDeprecatedJamDistThreshold; 00329 bool myHaveWarnedAboutDeprecatedVTypeProbe, myHaveWarnedAboutDeprecatedRouteProbe, 00330 myHaveWarnedAboutDeprecatedEdgeMean, myHaveWarnedAboutDeprecatedLaneMean; 00331 bool myHaveWarnedAboutDeprecatedVTypes, myHaveWarnedAboutDeprecatedLanes; 00332 bool myHaveWarnedAboutDeprecatedDistrict, myHaveWarnedAboutDeprecatedDSource, myHaveWarnedAboutDeprecatedDSink; 00333 00334 00335 private: 00337 NLHandler(const NLHandler& s); 00338 00340 NLHandler& operator=(const NLHandler& s); 00341 00342 }; 00343 00344 00345 #endif 00346 00347 /****************************************************************************/ 00348