SUMO - Simulation of Urban MObility
NLDetectorBuilder.h
Go to the documentation of this file.
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 printDefaults,
00445                                 const bool withInternal, const bool trackVehicles,
00446                                 const SUMOReal maxTravelTime, const SUMOReal minSamples,
00447                                 const SUMOReal haltSpeed, const std::string& vTypes,
00448                                 OutputDevice& device) throw(InvalidArgument);
00450 
00451 
00452 
00465     MSDetectorFileOutput* buildSingleLaneE2Det(const std::string& id,
00466             DetectorUsage usage, MSLane* lane, SUMOReal pos, SUMOReal length,
00467             SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
00468             SUMOReal jamDistThreshold) ;
00469 
00470 
00483     MSDetectorFileOutput* buildMultiLaneE2Det(const std::string& id, DetectorUsage usage, MSLane* lane, SUMOReal pos, SUMOReal length,
00484             SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
00485             SUMOReal jamDistThreshold) ;
00486 
00487 
00488 
00489 
00490 protected:
00495     class E3DetectorDefinition {
00496     public:
00504         E3DetectorDefinition(const std::string& id,
00505                              OutputDevice& device, SUMOReal haltingSpeedThreshold,
00506                              SUMOTime haltingTimeThreshold, int splInterval) ;
00507 
00509         ~E3DetectorDefinition() ;
00510 
00512         std::string myID;
00514         OutputDevice& myDevice;
00516         SUMOReal myHaltingSpeedThreshold;
00518         SUMOTime myHaltingTimeThreshold;
00520         CrossSectionVector myEntries;
00522         CrossSectionVector myExits;
00524         int mySampleInterval;
00526 
00527     private:
00529         E3DetectorDefinition(const E3DetectorDefinition&);
00530 
00532         E3DetectorDefinition& operator=(const E3DetectorDefinition&);
00533 
00534     };
00535 
00536 
00537 protected:
00554     SUMOReal getPositionChecking(SUMOReal pos, MSLane* lane, bool friendlyPos,
00555                                  const std::string& detid) throw(InvalidArgument);
00556 
00557 
00566     void convUncontE2PosLength(const std::string& id, MSLane* clane,
00567                                SUMOReal& pos, SUMOReal& length, bool frinedly_pos) throw(InvalidArgument);
00568 
00569 
00578     void convContE2PosLength(const std::string& id, MSLane* clane,
00579                              SUMOReal& pos, SUMOReal& length, bool frinedly_pos) throw(InvalidArgument);
00580 
00581 
00582 
00585 
00592     MSEdge* getEdgeChecking(const std::string& edgeID, SumoXMLTag type,
00593                             const std::string& detid) throw(InvalidArgument);
00594 
00595 
00602     MSLane* getLaneChecking(const std::string& laneID, SumoXMLTag type,
00603                             const std::string& detid) throw(InvalidArgument);
00604 
00605 
00613     void checkSampleInterval(int splInterval, SumoXMLTag type, const std::string& id) throw(InvalidArgument);
00615 
00616 
00617 protected:
00619     MSNet& myNet;
00620 
00621 
00622 private:
00624     E3DetectorDefinition* myE3Definition;
00625 
00626 
00627 private:
00629     NLDetectorBuilder(const NLDetectorBuilder&);
00630 
00632     NLDetectorBuilder& operator=(const NLDetectorBuilder&);
00633 
00634 };
00635 
00636 
00637 #endif
00638 
00639 /****************************************************************************/
00640 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines