|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // Builds detectors for microsim 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 NLDetectorBuilder_h 00024 #define NLDetectorBuilder_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 <string> 00037 #include <microsim/MSNet.h> 00038 #include <microsim/traffic_lights/MSTLLogicControl.h> 00039 #include <microsim/output/MSE3Collector.h> 00040 00041 00042 // =========================================================================== 00043 // class declarations 00044 // =========================================================================== 00045 class MSDetectorFileOutput; 00046 class MSLane; 00047 class MSEdge; 00048 00049 #ifdef HAVE_MESOSIM 00050 class MEInductLoop; 00051 class MESegment; 00052 #endif 00053 00054 00055 // =========================================================================== 00056 // class definitions 00057 // =========================================================================== 00065 class NLDetectorBuilder { 00066 public: 00071 NLDetectorBuilder(MSNet& net) ; 00072 00073 00075 virtual ~NLDetectorBuilder() ; 00076 00077 00080 00101 void buildInductLoop(const std::string& id, 00102 const std::string& lane, SUMOReal pos, int splInterval, 00103 OutputDevice& device, bool friendlyPos, bool splitByType) throw(InvalidArgument); 00104 00105 00121 void buildInstantInductLoop(const std::string& id, 00122 const std::string& lane, SUMOReal pos, 00123 OutputDevice& device, bool friendlyPos) throw(InvalidArgument); 00124 00125 00150 void buildE2Detector(const std::string& id, const std::string& lane, SUMOReal pos, SUMOReal length, 00151 bool cont, int splInterval, OutputDevice& device, SUMOTime haltingTimeThreshold, 00152 SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, 00153 bool friendlyPos) throw(InvalidArgument); 00154 00155 00180 void buildE2Detector(const std::string& id, const std::string& lane, SUMOReal pos, SUMOReal length, 00181 bool cont, MSTLLogicControl::TLSLogicVariants& tlls, 00182 OutputDevice& device, SUMOTime haltingTimeThreshold, 00183 SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, 00184 bool friendlyPos) throw(InvalidArgument); 00185 00186 00212 void buildE2Detector(const std::string& id, const std::string& lane, SUMOReal pos, SUMOReal length, 00213 bool cont, MSTLLogicControl::TLSLogicVariants& tlls, const std::string& tolane, 00214 OutputDevice& device, SUMOTime haltingTimeThreshold, 00215 SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, 00216 bool friendlyPos) throw(InvalidArgument); 00217 00218 00232 void beginE3Detector(const std::string& id, OutputDevice& device, int splInterval, 00233 SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold) throw(InvalidArgument); 00234 00235 00248 void addE3Entry(const std::string& lane, SUMOReal pos, bool friendlyPos) throw(InvalidArgument); 00249 00250 00263 void addE3Exit(const std::string& lane, SUMOReal pos, bool friendlyPos) throw(InvalidArgument); 00264 00265 00275 void endE3Detector() throw(InvalidArgument); 00276 00277 00285 std::string getCurrentE3ID() const ; 00286 00287 00301 void buildVTypeProbe(const std::string& id, 00302 const std::string& vtype, SUMOTime frequency, 00303 OutputDevice& device) throw(InvalidArgument); 00304 00305 00320 void buildRouteProbe(const std::string& id, const std::string& edge, 00321 SUMOTime frequency, SUMOTime begin, 00322 OutputDevice& device) throw(InvalidArgument); 00324 00325 00326 00331 00341 virtual MSDetectorFileOutput* createInductLoop(const std::string& id, 00342 MSLane* lane, SUMOReal pos, bool splitByType) ; 00343 00344 00354 virtual MSDetectorFileOutput* createInstantInductLoop(const std::string& id, 00355 MSLane* lane, SUMOReal pos, OutputDevice& od) ; 00356 00357 #ifdef HAVE_MESOSIM 00358 00367 virtual MEInductLoop* createMEInductLoop(const std::string& id, 00368 MESegment* s, SUMOReal pos) ; 00369 #endif 00370 00371 00384 virtual MSDetectorFileOutput* createSingleLaneE2Detector(const std::string& id, 00385 DetectorUsage usage, MSLane* lane, SUMOReal pos, SUMOReal length, 00386 SUMOTime haltingTimeThreshold, 00387 SUMOReal haltingSpeedThreshold, 00388 SUMOReal jamDistThreshold) ; 00389 00390 00404 virtual MSDetectorFileOutput* createMultiLaneE2Detector( 00405 const std::string& id, DetectorUsage usage, MSLane* lane, SUMOReal pos, 00406 SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, 00407 SUMOReal jamDistThreshold) ; 00408 00409 00420 virtual MSDetectorFileOutput* createE3Detector(const std::string& id, 00421 const CrossSectionVector& entries, const CrossSectionVector& exits, 00422 SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold) ; 00423 00424 00442 void createEdgeLaneMeanData(const std::string& id, SUMOTime frequency, 00443 SUMOTime begin, SUMOTime end, const std::string& type, 00444 const bool useLanes, const bool withEmpty, const bool withInternal, const bool trackVehicles, 00445 const SUMOReal maxTravelTime, const SUMOReal minSamples, 00446 const SUMOReal haltSpeed, const std::string& vTypes, 00447 OutputDevice& device) throw(InvalidArgument); 00449 00450 00451 00464 MSDetectorFileOutput* buildSingleLaneE2Det(const std::string& id, 00465 DetectorUsage usage, MSLane* lane, SUMOReal pos, SUMOReal length, 00466 SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, 00467 SUMOReal jamDistThreshold) ; 00468 00469 00482 MSDetectorFileOutput* buildMultiLaneE2Det(const std::string& id, DetectorUsage usage, MSLane* lane, SUMOReal pos, SUMOReal length, 00483 SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, 00484 SUMOReal jamDistThreshold) ; 00485 00486 00487 00488 00489 protected: 00494 class E3DetectorDefinition { 00495 public: 00503 E3DetectorDefinition(const std::string& id, 00504 OutputDevice& device, SUMOReal haltingSpeedThreshold, 00505 SUMOTime haltingTimeThreshold, int splInterval) ; 00506 00508 ~E3DetectorDefinition() ; 00509 00511 std::string myID; 00513 OutputDevice& myDevice; 00515 SUMOReal myHaltingSpeedThreshold; 00517 SUMOTime myHaltingTimeThreshold; 00519 CrossSectionVector myEntries; 00521 CrossSectionVector myExits; 00523 int mySampleInterval; 00525 00526 private: 00528 E3DetectorDefinition(const E3DetectorDefinition&); 00529 00531 E3DetectorDefinition& operator=(const E3DetectorDefinition&); 00532 00533 }; 00534 00535 00536 protected: 00553 SUMOReal getPositionChecking(SUMOReal pos, MSLane* lane, bool friendlyPos, 00554 const std::string& detid) throw(InvalidArgument); 00555 00556 00565 void convUncontE2PosLength(const std::string& id, MSLane* clane, 00566 SUMOReal& pos, SUMOReal& length, bool frinedly_pos) throw(InvalidArgument); 00567 00568 00577 void convContE2PosLength(const std::string& id, MSLane* clane, 00578 SUMOReal& pos, SUMOReal& length, bool frinedly_pos) throw(InvalidArgument); 00579 00580 00581 00584 00591 MSEdge* getEdgeChecking(const std::string& edgeID, SumoXMLTag type, 00592 const std::string& detid) throw(InvalidArgument); 00593 00594 00601 MSLane* getLaneChecking(const std::string& laneID, SumoXMLTag type, 00602 const std::string& detid) throw(InvalidArgument); 00603 00604 00612 void checkSampleInterval(int splInterval, SumoXMLTag type, const std::string& id) throw(InvalidArgument); 00614 00615 00616 protected: 00618 MSNet& myNet; 00619 00620 00621 private: 00623 E3DetectorDefinition* myE3Definition; 00624 00625 00626 private: 00628 NLDetectorBuilder(const NLDetectorBuilder&); 00629 00631 NLDetectorBuilder& operator=(const NLDetectorBuilder&); 00632 00633 }; 00634 00635 00636 #endif 00637 00638 /****************************************************************************/ 00639