|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The basic traffic light logic 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 MSUnboundActuatedTrafficLightLogic_h 00020 #define MSUnboundActuatedTrafficLightLogic_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 <utility> 00033 #include <vector> 00034 #include <bitset> 00035 #include <map> 00036 #include <microsim/MSEventControl.h> 00037 #include <microsim/traffic_lights/MSTrafficLightLogic.h> 00038 #include "MSActuatedPhaseDefinition.h" 00039 #include "MSSimpleTrafficLightLogic.h" 00040 #include <microsim/output/MSInductLoop.h> 00041 #include <microsim/MSLaneState.h> 00042 00043 00044 // =========================================================================== 00045 // class declarations 00046 // =========================================================================== 00047 class NLDetectorBuilder; 00048 00049 00050 // =========================================================================== 00051 // class definitions 00052 // =========================================================================== 00061 class MSUnboundActuatedTrafficLightLogic : 00062 public MSSimpleTrafficLightLogic { 00063 public: 00065 typedef std::map<MSLane*, MSInductLoop*> InductLoopMap; 00066 00068 typedef std::map<MSLane*, MSLaneState*> LaneStateMap; 00069 00070 public: 00072 MSUnboundActuatedTrafficLightLogic(const std::string& id, 00073 const MSSimpleTrafficLightLogic::Phases& phases, 00074 size_t step, size_t delay, 00075 SUMOReal maxGap, SUMOReal passingTime, SUMOReal detectorGap); 00076 00078 void init(NLDetectorBuilder& nb, 00079 const std::vector<MSLane*> &lanes, 00080 std::map<std::string, std::vector<std::string> > &edgeContinuations, 00081 SUMOReal det_offset); 00082 00084 ~MSUnboundActuatedTrafficLightLogic(); 00085 00088 SUMOTime trySwitch(bool isActive); 00089 00091 SUMOTime duration() const; 00092 00094 bool gapControl(); 00095 00096 // Checkes wheter the tested phase is a neither a yellow nor a allred phase 00097 bool isGreenPhase() const ; 00098 00099 protected: 00101 MSActuatedPhaseDefinition* currentPhaseDef() const; 00102 00103 protected: 00105 InductLoopMap myInductLoops; 00106 00108 LaneStateMap myLaneStates; 00109 00111 bool myContinue; 00112 00114 SUMOReal myMaxGap; 00115 00117 SUMOReal myPassingTime; 00118 00120 SUMOReal myDetectorGap; 00121 00122 }; 00123 00124 00125 #endif 00126 00127 /****************************************************************************/ 00128