SUMO - Simulation of Urban MObility
NLJunctionControlBuilder.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // Builder of microsim-junctions and tls
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef NLJunctionControlBuilder_h
00023 #define NLJunctionControlBuilder_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <string>
00036 #include <vector>
00037 #include <microsim/MSJunction.h>
00038 #include <microsim/MSRightOfWayJunction.h>
00039 #include <microsim/MSJunctionControl.h>
00040 #include <utils/geom/Position.h>
00041 #include <utils/geom/PositionVector.h>
00042 #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h>
00043 #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h>
00044 #include <microsim/MSBitSetLogic.h>
00045 #include <microsim/traffic_lights/MSTLLogicControl.h>
00046 #include <utils/common/UtilExceptions.h>
00047 
00048 
00049 // ===========================================================================
00050 // class declarations
00051 // ===========================================================================
00052 class OptionsCont;
00053 class NLDetectorBuilder;
00054 
00055 
00056 // ===========================================================================
00057 // class definitions
00058 // ===========================================================================
00069 class NLJunctionControlBuilder {
00070 private:
00072     typedef std::vector<MSLane*> LaneVector;
00073 
00074 public:
00082     NLJunctionControlBuilder(MSNet& net, NLDetectorBuilder& db) ;
00083 
00084 
00090     virtual ~NLJunctionControlBuilder() ;
00091 
00092 
00106     void openJunction(const std::string& id, const std::string& key,
00107                       const std::string& type, SUMOReal x, SUMOReal y,
00108                       const PositionVector& shape,
00109                       const std::vector<MSLane*> &incomingLanes,
00110                       const std::vector<MSLane*> &internalLanes) throw(InvalidArgument);
00111 
00112 
00125     void closeJunction() throw(InvalidArgument, ProcessError);
00126 
00127 
00135     MSJunctionControl* build() const ;
00136 
00137 
00141     void initJunctionLogic(const std::string& id) ;
00142 
00143 
00155     void addLogicItem(int request, const std::string& response,
00156                       const std::string& foes, bool cont) throw(InvalidArgument);
00157 
00158 
00168     void initTrafficLightLogic(const std::string& id, const std::string& programID,
00169                                TrafficLightType type, SUMOTime offset) ;
00170 
00171 
00181     void addPhase(SUMOTime duration, const std::string& state,
00182                   int min, int max) ;
00183 
00184 
00191     MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id)
00192     const throw(InvalidArgument);
00193 
00194 
00204     MSTLLogicControl* buildTLLogics() const ;
00205 
00206 
00215     virtual void closeTrafficLightLogic() throw(InvalidArgument, ProcessError);
00216 
00217 
00228     void closeJunctionLogic() throw(InvalidArgument);
00229 
00230 
00238     void addParam(const std::string& key, const std::string& value) ;
00239 
00240 
00244     const std::string& getActiveKey() const ;
00245 
00246 
00250     const std::string& getActiveSubKey() const ;
00251 
00252 
00260     MSTLLogicControl& getTLLogicControlToUse() const ;
00261 
00262 
00263 protected:
00273     MSJunctionLogic* getJunctionLogicSecure() throw(InvalidArgument);
00274 
00275 
00276 protected:
00279 
00286     virtual MSJunction* buildNoLogicJunction() ;
00287 
00288 
00297     virtual MSJunction* buildLogicJunction() throw(InvalidArgument);
00298 
00299 
00300 #ifdef HAVE_INTERNAL_LANES
00301 
00307     virtual MSJunction* buildInternalJunction() ;
00308 #endif
00309 
00310 
00311 
00312 protected:
00314     MSNet& myNet;
00315 
00317     NLDetectorBuilder& myDetectorBuilder;
00318 
00320     SUMOTime myOffset;
00321 
00323     TrafficLightType myLogicType;
00324 
00326     MSBitsetLogic::Logic myActiveLogic;
00327 
00329     MSBitsetLogic::Foes myActiveFoes;
00330 
00332     std::bitset<64> myActiveConts;
00333 
00335     MSSimpleTrafficLightLogic::Phases myActivePhases;
00336 
00338     int myRequestSize;
00339 
00341     int myRequestItemNumber;
00342 
00344     mutable MSJunctionControl* myJunctions;
00345 
00347     LaneVector myActiveIncomingLanes;
00348 
00349 #ifdef HAVE_INTERNAL_LANES
00350 
00351     LaneVector myActiveInternalLanes;
00352 #endif
00353 
00355     std::string myActiveID;
00356 
00358     std::string myActiveKey, myActiveProgram;
00359 
00361     SumoXMLNodeType myType;
00362 
00364     Position myPosition;
00365 
00367     SUMOTime myAbsDuration;
00368 
00370     PositionVector myShape;
00371 
00372 
00374     struct TLInitInfo {
00376         MSTrafficLightLogic* logic;
00378         std::map<std::string, std::string> params;
00379     };
00380 
00382     std::vector<TLInitInfo> myJunctions2PostLoadInit;
00383 
00384 
00386     mutable MSTLLogicControl* myLogicControl;
00387 
00388 
00390     typedef std::map<std::string, std::string> StringParameterMap;
00391 
00393     StringParameterMap myAdditionalParameter;
00394 
00395 
00397     std::map<std::string, MSJunctionLogic*> myLogics;
00398 
00400     bool myCurrentHasError;
00401 
00402 
00403 private:
00405     NLJunctionControlBuilder(const NLJunctionControlBuilder& s);
00406 
00408     NLJunctionControlBuilder& operator=(const NLJunctionControlBuilder& s);
00409 
00410     static const int NO_REQUEST_SIZE;
00411 
00412 };
00413 
00414 
00415 #endif
00416 
00417 /****************************************************************************/
00418 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines