NLJunctionControlBuilder.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Builder of microsim-junctions and tls
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 NLJunctionControlBuilder_h
00020 #define NLJunctionControlBuilder_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 <vector>
00034 #include <microsim/MSJunction.h>
00035 #include <microsim/MSRightOfWayJunction.h>
00036 #include <microsim/MSJunctionControl.h>
00037 #include <utils/geom/Position2D.h>
00038 #include <utils/geom/Position2DVector.h>
00039 #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h>
00040 #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h>
00041 #include <microsim/MSBitSetLogic.h>
00042 #include <microsim/traffic_lights/MSTLLogicControl.h>
00043 #include <utils/common/UtilExceptions.h>
00044 
00045 
00046 // ===========================================================================
00047 // class declarations
00048 // ===========================================================================
00049 class OptionsCont;
00050 
00051 
00052 // ===========================================================================
00053 // class definitions
00054 // ===========================================================================
00065 class NLJunctionControlBuilder {
00066 private:
00068     typedef std::vector<MSLane*> LaneVector;
00069 
00070 public:
00080     NLJunctionControlBuilder(MSNet &net, OptionsCont &oc) throw();
00081 
00082 
00088     virtual ~NLJunctionControlBuilder() throw();
00089 
00090 
00102     void openJunction(const std::string &id, const std::string &key,
00103                       const std::string &type, SUMOReal x, SUMOReal y,
00104                       const Position2DVector &shape) throw(InvalidArgument);
00105 
00106 
00111     void addIncomingLane(MSLane *lane) throw();
00112 
00113 
00114 #ifdef HAVE_INTERNAL_LANES
00115 
00119     void addInternalLane(MSLane *lane) throw();
00120 #endif
00121 
00122 
00127     void addJunctionShape(const Position2DVector &shape) throw();
00128 
00129 
00142     void closeJunction() throw(InvalidArgument, ProcessError);
00143 
00144 
00152     MSJunctionControl *build() const throw();
00153 
00154 
00159     void initIncomingLanes() throw();
00160 
00161 
00167     void initJunctionLogic(const std::string &id, int requestSize, int laneNumber) throw();
00168 
00169 
00181     void addLogicItem(int request, const std::string &response,
00182                       const std::string &foes, bool cont) throw(InvalidArgument);
00183 
00184 
00196     void initTrafficLightLogic(const std::string &id, const std::string &programID,
00197                                const std::string &type, int offset, SUMOReal detectorOffset) throw();
00198 
00199 
00209     void addPhase(SUMOTime duration, const std::string &state,
00210                   int min, int max) throw();
00211 
00212 
00218     void setRequestSize(int size) throw();
00219 
00220 
00226     void setLaneNumber(int size) throw();
00227 
00228 
00233     void setKey(const std::string &key) throw();
00234 
00235 
00240     void setSubKey(const std::string &subkey) throw();
00241 
00242 
00248     void setOffset(int val) throw();
00249 
00250 
00257     MSTLLogicControl::TLSLogicVariants &getTLLogic(const std::string &id)
00258     const throw(InvalidArgument);
00259 
00260 
00270     MSTLLogicControl *buildTLLogics() const throw(ProcessError);
00271 
00272 
00281     virtual void closeTrafficLightLogic() throw(InvalidArgument, ProcessError);
00282 
00283 
00294     void closeJunctionLogic() throw(InvalidArgument);
00295 
00296 
00306     void closeJunctions(NLDetectorBuilder &db) throw();
00307 
00308 
00316     void addParam(const std::string &key, const std::string &value) throw();
00317 
00318 
00322     const std::string &getActiveID() const throw();
00323 
00324 
00328     const std::string &getActiveKey() const throw();
00329 
00330 
00334     const std::string &getActiveSubKey() const throw();
00335 
00336 
00344     MSTLLogicControl &getTLLogicControlToUse() const throw();
00345 
00346 
00347 protected:
00357     MSJunctionLogic *getJunctionLogicSecure() throw(InvalidArgument);
00358 
00359 
00360 protected:
00363 
00370     virtual MSJunction *buildNoLogicJunction() throw();
00371 
00372 
00381     virtual MSJunction *buildLogicJunction() throw(InvalidArgument);
00382 
00383 
00384 #ifdef HAVE_INTERNAL_LANES
00385 
00391     virtual MSJunction *buildInternalJunction() throw();
00392 #endif
00394 
00395 
00396 protected:
00401     enum JunctionType {
00403         TYPE_UNKNOWN = 0,
00405         TYPE_NOJUNCTION,
00407         TYPE_RIGHT_BEFORE_LEFT,
00409         TYPE_PRIORITY_JUNCTION,
00411         TYPE_DEAD_END,
00413         TYPE_INTERNAL
00414     };
00415 
00416 
00417 protected:
00419     MSNet &myNet;
00420 
00422     SUMOTime myOffset;
00423 
00425     std::string myLogicType;
00426 
00428     MSBitsetLogic::Logic *myActiveLogic;
00429 
00431     MSBitsetLogic::Foes *myActiveFoes;
00432 
00434     std::bitset<64> myActiveConts;
00435 
00437     MSSimpleTrafficLightLogic::Phases myActivePhases;
00438 
00440     int myRequestSize;
00441 
00443     int myLaneNumber;
00444 
00446     int myRequestItemNumber;
00447 
00449     mutable MSJunctionControl *myJunctions;
00450 
00452     LaneVector myActiveIncomingLanes;
00453 
00454 #ifdef HAVE_INTERNAL_LANES
00456     LaneVector myActiveInternalLanes;
00457 #endif
00458 
00460     std::string myActiveID;
00461 
00463     std::string myActiveKey, myActiveSubKey;
00464 
00466     JunctionType myType;
00467 
00469     Position2D myPosition;
00470 
00472     SUMOTime myAbsDuration;
00473 
00475     Position2DVector myShape;
00476 
00477 
00479     struct TLInitInfo {
00481         MSTrafficLightLogic *logic;
00483         std::map<std::string, std::string> params;
00484     };
00485 
00487     std::vector<TLInitInfo> myJunctions2PostLoadInit;
00488 
00492 
00494     SUMOReal myDetectorOffset;
00495 
00497     SUMOReal myStdDetectorPositions;
00498 
00500     SUMOReal myStdDetectorLengths;
00501 
00503     int myStdLearnHorizon;
00504 
00506     int myStdDecisionHorizon;
00507 
00509     SUMOReal myStdDeltaLimit;
00510 
00512     int myStdTCycle;
00513 
00514     // @brief Default maximum gap  (actuated)
00515     SUMOReal myStdActuatedMaxGap;
00516 
00517     // @brief Default passing time (actuated)
00518     SUMOReal myStdActuatedPassingTime;
00519 
00520     // @brief Default maximum gap (actuated)
00521     SUMOReal myStdActuatedDetectorGap;
00523 
00524 
00526     mutable MSTLLogicControl *myLogicControl;
00527 
00528 
00530     typedef std::map<std::string, std::string> StringParameterMap;
00531 
00533     StringParameterMap myAdditionalParameter;
00534 
00535 
00537     std::map<std::string, MSJunctionLogic*> myLogics;
00538 
00540     bool myCurrentHasError;
00541 
00542 
00543 private:
00545     NLJunctionControlBuilder(const NLJunctionControlBuilder &s);
00546 
00548     NLJunctionControlBuilder &operator=(const NLJunctionControlBuilder &s);
00549 
00550 };
00551 
00552 
00553 #endif
00554 
00555 /****************************************************************************/
00556 

Generated on Wed May 5 00:06:35 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6