|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Builder of microsim-junctions and tls 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 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/Position.h> 00038 #include <utils/geom/PositionVector.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 class NLDetectorBuilder; 00051 00052 00053 // =========================================================================== 00054 // class definitions 00055 // =========================================================================== 00066 class NLJunctionControlBuilder { 00067 private: 00069 typedef std::vector<MSLane*> LaneVector; 00070 00071 public: 00079 NLJunctionControlBuilder(MSNet& net, NLDetectorBuilder& db) throw(); 00080 00081 00087 virtual ~NLJunctionControlBuilder() throw(); 00088 00089 00103 void openJunction(const std::string& id, const std::string& key, 00104 const std::string& type, SUMOReal x, SUMOReal y, 00105 const PositionVector& shape, 00106 const std::vector<MSLane*> &incomingLanes, 00107 const std::vector<MSLane*> &internalLanes) throw(InvalidArgument); 00108 00109 00122 void closeJunction() throw(InvalidArgument, ProcessError); 00123 00124 00132 MSJunctionControl* build() const throw(); 00133 00134 00138 void initJunctionLogic(const std::string& id) throw(); 00139 00140 00152 void addLogicItem(int request, const std::string& response, 00153 const std::string& foes, bool cont) throw(InvalidArgument); 00154 00155 00165 void initTrafficLightLogic(const std::string& id, const std::string& programID, 00166 TrafficLightType type, SUMOTime offset) throw(); 00167 00168 00178 void addPhase(SUMOTime duration, const std::string& state, 00179 int min, int max) throw(); 00180 00181 00188 MSTLLogicControl::TLSLogicVariants& getTLLogic(const std::string& id) 00189 const throw(InvalidArgument); 00190 00191 00201 MSTLLogicControl* buildTLLogics() const throw(ProcessError); 00202 00203 00212 virtual void closeTrafficLightLogic() throw(InvalidArgument, ProcessError); 00213 00214 00225 void closeJunctionLogic() throw(InvalidArgument); 00226 00227 00235 void addParam(const std::string& key, const std::string& value) throw(); 00236 00237 00241 const std::string& getActiveKey() const throw(); 00242 00243 00247 const std::string& getActiveSubKey() const throw(); 00248 00249 00257 MSTLLogicControl& getTLLogicControlToUse() const throw(); 00258 00259 00260 protected: 00270 MSJunctionLogic* getJunctionLogicSecure() throw(InvalidArgument); 00271 00272 00273 protected: 00276 00283 virtual MSJunction* buildNoLogicJunction() throw(); 00284 00285 00294 virtual MSJunction* buildLogicJunction() throw(InvalidArgument); 00295 00296 00297 #ifdef HAVE_INTERNAL_LANES 00298 00304 virtual MSJunction* buildInternalJunction() throw(); 00305 #endif 00306 00307 00308 00309 protected: 00311 MSNet& myNet; 00312 00314 NLDetectorBuilder& myDetectorBuilder; 00315 00317 SUMOTime myOffset; 00318 00320 TrafficLightType myLogicType; 00321 00323 MSBitsetLogic::Logic myActiveLogic; 00324 00326 MSBitsetLogic::Foes myActiveFoes; 00327 00329 std::bitset<64> myActiveConts; 00330 00332 MSSimpleTrafficLightLogic::Phases myActivePhases; 00333 00335 int myRequestSize; 00336 00338 int myRequestItemNumber; 00339 00341 mutable MSJunctionControl* myJunctions; 00342 00344 LaneVector myActiveIncomingLanes; 00345 00346 #ifdef HAVE_INTERNAL_LANES 00347 00348 LaneVector myActiveInternalLanes; 00349 #endif 00350 00352 std::string myActiveID; 00353 00355 std::string myActiveKey, myActiveProgram; 00356 00358 SumoXMLNodeType myType; 00359 00361 Position myPosition; 00362 00364 SUMOTime myAbsDuration; 00365 00367 PositionVector myShape; 00368 00369 00371 struct TLInitInfo { 00373 MSTrafficLightLogic* logic; 00375 std::map<std::string, std::string> params; 00376 }; 00377 00379 std::vector<TLInitInfo> myJunctions2PostLoadInit; 00380 00381 00383 mutable MSTLLogicControl* myLogicControl; 00384 00385 00387 typedef std::map<std::string, std::string> StringParameterMap; 00388 00390 StringParameterMap myAdditionalParameter; 00391 00392 00394 std::map<std::string, MSJunctionLogic*> myLogics; 00395 00397 bool myCurrentHasError; 00398 00399 00400 private: 00402 NLJunctionControlBuilder(const NLJunctionControlBuilder& s); 00403 00405 NLJunctionControlBuilder& operator=(const NLJunctionControlBuilder& s); 00406 00407 static const int NO_REQUEST_SIZE; 00408 00409 }; 00410 00411 00412 #endif 00413 00414 /****************************************************************************/ 00415