SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Intermediate class for storing visum traffic lights during their import 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This file is part of SUMO. 00014 // SUMO is free software: you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation, either version 3 of the License, or 00017 // (at your option) any later version. 00018 // 00019 /****************************************************************************/ 00020 #ifndef NIVisumTL_h 00021 #define NIVisumTL_h 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <vector> 00034 #include <map> 00035 #include <string> 00036 #include <netbuild/NBConnectionDefs.h> 00037 #include <netbuild/NBNodeCont.h> 00038 #include <utils/common/SUMOTime.h> 00039 00040 class NBTrafficLightLogicCont; 00041 00042 00043 // =========================================================================== 00044 // class declaration 00045 // =========================================================================== 00050 class NIVisumTL { 00051 public: 00055 class TimePeriod { 00056 public: 00058 TimePeriod(SUMOTime startTime, SUMOTime endTime) : myStartTime(startTime), myEndTime(endTime) {} 00059 00061 ~TimePeriod() {} 00062 00064 SUMOTime getStartTime() { 00065 return myStartTime; 00066 } 00067 00069 SUMOTime getEndTime() { 00070 return myEndTime; 00071 } 00072 00073 private: 00075 SUMOTime myStartTime; 00077 SUMOTime myEndTime; 00078 }; 00079 00080 00081 00085 class Phase : public TimePeriod { 00086 public: 00088 Phase(SUMOTime startTime, SUMOTime endTime) : NIVisumTL::TimePeriod(startTime, endTime) {} 00089 00091 ~Phase() {} 00092 00093 }; 00094 00095 00096 00100 class SignalGroup : public TimePeriod { 00101 public: 00103 SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime) 00104 : NIVisumTL::TimePeriod(startTime, endTime), myName(name) {} 00105 00107 ~SignalGroup() {} 00108 00110 NBConnectionVector &connections() { 00111 return myConnections; 00112 } 00113 00115 std::map<std::string, Phase*> &phases() { 00116 return myPhases; 00117 } 00118 00119 private: 00121 NBConnectionVector myConnections; 00123 std::map<std::string, Phase*> myPhases; 00125 std::string myName; 00126 }; 00127 00128 00129 00130 public: 00137 NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime intermediateTime, 00138 bool phaseDefined); 00139 00141 ~NIVisumTL(); 00142 00144 void addNode(NBNode *n) { 00145 myNodes.push_back(n); 00146 } 00147 00149 void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime); 00150 00152 void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime); 00153 00155 std::map<std::string, Phase*>& getPhases() { 00156 return myPhases; 00157 } 00158 00160 SignalGroup& getSignalGroup(const std::string &name); 00161 00163 void build(NBTrafficLightLogicCont& tlc); 00164 00165 private: 00166 // name of traffic light 00167 std::string myName; 00168 00169 // cycle time of traffic light in seconds 00170 SUMOTime myCycleTime; 00171 00172 // length of yellow and red-yellow phases 00173 SUMOTime myIntermediateTime; 00174 00175 // toogles the usage either of phases or of timeperiods in signalgroups 00176 bool myPhaseDefined; 00177 00178 // vector of nodes belonging to this traffic light 00179 std::vector<NBNode*> myNodes; 00180 00181 // vector of used phases if phasedefined 00182 std::map<std::string, Phase*> myPhases; 00183 00184 // vector of used Signalgroups 00185 std::map<std::string, SignalGroup*> mySignalGroups; 00186 00187 }; 00188 00189 00190 #endif 00191 00192 /****************************************************************************/ 00193