SUMO - Simulation of Urban MObility

NLHandler.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The XML-Handler for network loading
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 NLHandler_h
00020 #define NLHandler_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 <xercesc/sax/HandlerBase.hpp>
00033 #include <xercesc/sax/SAXException.hpp>
00034 #include <xercesc/sax/AttributeList.hpp>
00035 #include <utils/common/SUMOTime.h>
00036 #include <utils/xml/SUMOXMLDefinitions.h>
00037 #include <microsim/MSLink.h>
00038 #include <microsim/MSRouteHandler.h>
00039 #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h>
00040 #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h>
00041 #include <microsim/MSBitSetLogic.h>
00042 #include "NLBuilder.h"
00043 #include "NLDiscreteEventBuilder.h"
00044 #include "NLSucceedingLaneBuilder.h"
00045 
00046 
00047 // ===========================================================================
00048 // class declarations
00049 // ===========================================================================
00050 class NLContainer;
00051 class NLDetectorBuilder;
00052 class NLTriggerBuilder;
00053 class MSTrafficLightLogic;
00054 
00055 
00056 // ===========================================================================
00057 // class definitions
00058 // ===========================================================================
00067 class NLHandler : public MSRouteHandler {
00068 public:
00070     typedef std::vector<MSLane*> LaneVector;
00071 
00072 public:
00082     NLHandler(const std::string& file, MSNet& net,
00083               NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
00084               NLEdgeControlBuilder& edgeBuilder,
00085               NLJunctionControlBuilder& junctionBuilder) throw();
00086 
00087 
00089     virtual ~NLHandler() throw();
00090 
00091 
00092 protected:
00094 
00095 
00104     virtual void myStartElement(int element,
00105                                 const SUMOSAXAttributes& attrs) throw(ProcessError);
00106 
00107 
00115     virtual void myEndElement(int element) throw(ProcessError);
00117 
00118 
00119 protected:
00120     void addParam(const SUMOSAXAttributes& attrs);
00121 
00125     virtual void addE1Detector(const SUMOSAXAttributes& attrs);
00126 
00130     virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
00131 
00135     virtual void addE2Detector(const SUMOSAXAttributes& attrs);
00136 
00140     void beginE3Detector(const SUMOSAXAttributes& attrs);
00141 
00145     void addE3Entry(const SUMOSAXAttributes& attrs);
00146 
00150     void addE3Exit(const SUMOSAXAttributes& attrs);
00151 
00153     virtual void endE3Detector();
00154 
00158     virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
00159 
00163     virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
00164 
00169     virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
00170 
00172     virtual void closeEdge();
00173 
00174 
00175 protected:
00177     MSNet& myNet;
00178 
00179 
00180 private:
00182     void beginEdgeParsing(const SUMOSAXAttributes& attrs);
00183 
00185     void addLane(const SUMOSAXAttributes& attrs);
00186 
00188     void addPOI(const SUMOSAXAttributes& attrs);
00189 
00191     void addPoly(const SUMOSAXAttributes& attrs);
00192 
00194     void addLogicItem(const SUMOSAXAttributes& attrs);
00195 
00197     void addRequest(const SUMOSAXAttributes& attrs);
00198 
00200     void initJunctionLogic(const SUMOSAXAttributes& attrs);
00201 
00203     void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
00204 
00206     void addPhase(const SUMOSAXAttributes& attrs);
00207 
00208 
00210     virtual void openJunction(const SUMOSAXAttributes& attrs);
00211 
00212     void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*> &into, bool& ok);
00213 
00214 #ifdef _MESSAGES
00215 
00216     void addMsgEmitter(const SUMOSAXAttributes& attrs);
00217 #endif
00218 
00220     void openSucc(const SUMOSAXAttributes& attrs);
00221 
00223     void addSuccLane(const SUMOSAXAttributes& attrs);
00224 
00226     void addConnection(const SUMOSAXAttributes& attrs);
00227 
00228     virtual void openWAUT(const SUMOSAXAttributes& attrs);
00229     void addWAUTSwitch(const SUMOSAXAttributes& attrs);
00230     void addWAUTJunction(const SUMOSAXAttributes& attrs);
00231 
00233     void setLocation(const SUMOSAXAttributes& attrs);
00234 
00244     void addDistrict(const SUMOSAXAttributes& attrs) throw(ProcessError);
00245 
00246 
00257     void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
00258 
00259 
00260     void closeWAUT();
00261 
00263     void closeSuccLane();
00264 
00266     LinkDirection parseLinkDir(const std::string& dir);
00267 
00269     LinkState parseLinkState(const std::string& state);
00270 
00272     std::pair<MSLane*, MSLane*> getLanesFromIndices(MSEdge* from, MSEdge* to, const std::string& laneIndices, bool& ok);
00273 
00274 
00275 protected:
00277     NLDiscreteEventBuilder myActionBuilder;
00278 
00280     bool myCurrentIsInternalToSkip;
00281 
00282 
00284     NLDetectorBuilder& myDetectorBuilder;
00285 
00287     NLTriggerBuilder& myTriggerBuilder;
00288 
00290     NLEdgeControlBuilder& myEdgeControlBuilder;
00291 
00293     NLJunctionControlBuilder& myJunctionControlBuilder;
00294 
00296     NLSucceedingLaneBuilder mySucceedingLaneBuilder;
00297 
00298 
00299 
00301     std::string myCurrentDistrictID;
00302 
00304     bool myAmInTLLogicMode;
00305 
00307     std::string myCurrentWAUTID;
00308 
00310     Position myNetworkOffset;
00311 
00313     Boundary myOrigBoundary, myConvBoundary;
00314 
00315     bool myCurrentIsBroken;
00316 
00317     bool myHaveWarnedAboutDeprecatedE1, myHaveWarnedAboutDeprecatedE2,
00318          myHaveWarnedAboutDeprecatedE3, myHaveWarnedAboutDeprecatedDetEntry,
00319          myHaveWarnedAboutDeprecatedDetExit, myHaveWarnedAboutDeprecatedTimedEvent;
00320     bool myHaveWarnedAboutDeprecatedRowLogic, myHaveWarnedAboutDeprecatedTLLogic;
00321     bool myHaveWarnedAboutDeprecatedTLSTiming;
00322     bool myHaveWarnedAboutDeprecatedTimeThreshold,
00323          myHaveWarnedAboutDeprecatedSpeedThreshold,
00324          myHaveWarnedAboutDeprecatedJamDistThreshold;
00325     bool myHaveWarnedAboutDeprecatedVTypeProbe, myHaveWarnedAboutDeprecatedRouteProbe,
00326          myHaveWarnedAboutDeprecatedEdgeMean, myHaveWarnedAboutDeprecatedLaneMean;
00327     bool myHaveWarnedAboutDeprecatedVTypes, myHaveWarnedAboutDeprecatedLanes;
00328     bool myHaveWarnedAboutDeprecatedDistrict, myHaveWarnedAboutDeprecatedDSource, myHaveWarnedAboutDeprecatedDSink;
00329 
00330 
00331 private:
00333     NLHandler(const NLHandler& s);
00334 
00336     NLHandler& operator=(const NLHandler& s);
00337 
00338 };
00339 
00340 
00341 #endif
00342 
00343 /****************************************************************************/
00344 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines