SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVisumTL.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // Intermediate class for storing visum traffic lights during their import
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef NIVisumTL_h
21 #define NIVisumTL_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <map>
35 #include <string>
37 #include <netbuild/NBNodeCont.h>
38 #include <utils/common/SUMOTime.h>
39 
41 
42 
43 // ===========================================================================
44 // class declaration
45 // ===========================================================================
50 class NIVisumTL {
51 public:
55  class TimePeriod {
56  public:
58  TimePeriod(SUMOTime startTime, SUMOTime endTime) : myStartTime(startTime), myEndTime(endTime) {}
59 
62 
65  return myStartTime;
66  }
67 
70  return myEndTime;
71  }
72 
73  private:
78  };
79 
80 
81 
85  class Phase : public TimePeriod {
86  public:
88  Phase(SUMOTime startTime, SUMOTime endTime) : NIVisumTL::TimePeriod(startTime, endTime) {}
89 
91  ~Phase() {}
92 
93  };
94 
95 
96 
100  class SignalGroup : public TimePeriod {
101  public:
103  SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime)
104  : NIVisumTL::TimePeriod(startTime, endTime), myName(name) {}
105 
108 
111  return myConnections;
112  }
113 
115  std::map<std::string, Phase*> &phases() {
116  return myPhases;
117  }
118 
119  private:
123  std::map<std::string, Phase*> myPhases;
125  std::string myName;
126  };
127 
128 
129 
130 public:
137  NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime intermediateTime,
138  bool phaseDefined);
139 
141  ~NIVisumTL();
142 
144  void addNode(NBNode *n) {
145  myNodes.push_back(n);
146  }
147 
149  void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime);
150 
152  void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime);
153 
155  std::map<std::string, Phase*>& getPhases() {
156  return myPhases;
157  }
158 
160  SignalGroup& getSignalGroup(const std::string &name);
161 
163  void build(NBTrafficLightLogicCont& tlc);
164 
165 private:
166  // name of traffic light
167  std::string myName;
168 
169  // cycle time of traffic light in seconds
171 
172  // length of yellow and red-yellow phases
174 
175  // toogles the usage either of phases or of timeperiods in signalgroups
177 
178  // vector of nodes belonging to this traffic light
179  std::vector<NBNode*> myNodes;
180 
181  // vector of used phases if phasedefined
182  std::map<std::string, Phase*> myPhases;
183 
184  // vector of used Signalgroups
185  std::map<std::string, SignalGroup*> mySignalGroups;
186 
187 };
188 
189 
190 #endif
191 
192 /****************************************************************************/
193