SUMO - Simulation of Urban MObility
NIVisumTL.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Intermediate class for storing visum traffic lights during their import
18 /****************************************************************************/
19 #ifndef NIVisumTL_h
20 #define NIVisumTL_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <vector>
33 #include <map>
34 #include <string>
36 #include <netbuild/NBNodeCont.h>
37 #include <utils/common/SUMOTime.h>
38 
40 class NBEdgeCont;
41 
42 
43 // ===========================================================================
44 // class declaration
45 // ===========================================================================
50 class NIVisumTL {
51 public:
55  class TimePeriod {
56  public:
58  TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
59  : myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}
60 
63 
66  return myStartTime;
67  }
68 
71  return myEndTime;
72  }
73 
76  return myYellowTime;
77  }
78 
79  private:
86  };
87 
88 
89 
93  class Phase : public TimePeriod {
94  public:
96  Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}
97 
99  ~Phase() {}
100 
101  };
102 
103 
104 
108  class SignalGroup : public TimePeriod {
109  public:
111  SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
112  : NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}
113 
116 
119  return myConnections;
120  }
121 
123  std::map<std::string, Phase*>& phases() {
124  return myPhases;
125  }
126 
127  private:
131  std::map<std::string, Phase*> myPhases;
133  std::string myName;
134  };
135 
136 
137 
138 public:
146  NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,
147  bool phaseDefined);
148 
150  ~NIVisumTL();
151 
153  void addNode(NBNode* n) {
154  myNodes.push_back(n);
155  }
156 
158  void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
159 
161  void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
162 
164  std::map<std::string, Phase*>& getPhases() {
165  return myPhases;
166  }
167 
169  SignalGroup& getSignalGroup(const std::string& name);
170 
172  void build(NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
173 
174 private:
176  std::string myName;
177 
180 
183 
186 
189 
191  std::vector<NBNode*> myNodes;
192 
194  std::map<std::string, Phase*> myPhases;
195 
197  std::map<std::string, SignalGroup*> mySignalGroups;
198 
199 
200 };
201 
202 
203 #endif
204 
205 /****************************************************************************/
206 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:123
bool myPhaseDefined
Toogles the usage either of phases or of time periods in signal groups.
Definition: NIVisumTL.h:188
~SignalGroup()
destructor
Definition: NIVisumTL.h:115
SUMOTime myYellowTime
Yellow time.
Definition: NIVisumTL.h:85
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:108
A time period with a start and an end time.
Definition: NIVisumTL.h:55
NBConnectionVector myConnections
Connections.
Definition: NIVisumTL.h:129
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition: NIVisumTL.h:75
A container for traffic light definitions and built programs.
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:96
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition: NIVisumTL.cpp:73
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:58
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition: NIVisumTL.h:179
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition: NIVisumTL.cpp:67
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:61
A phase.
Definition: NIVisumTL.h:93
SUMOTime myEndTime
End time.
Definition: NIVisumTL.h:83
SUMOTime getEndTime()
Returns the stored end time.
Definition: NIVisumTL.h:70
~TimePeriod()
Destructor.
Definition: NIVisumTL.h:62
~NIVisumTL()
Destructor.
Definition: NIVisumTL.cpp:50
SUMOTime getStartTime()
Returns the stored start time.
Definition: NIVisumTL.h:65
std::string myName
name
Definition: NIVisumTL.h:133
SUMOTime myOffset
The offset in the plan.
Definition: NIVisumTL.h:182
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:79
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:43
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:111
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
SUMOTime myStartTime
Start time.
Definition: NIVisumTL.h:81
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition: NIVisumTL.h:197
void addNode(NBNode *n)
Adds a node to control.
Definition: NIVisumTL.h:153
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
std::string myName
The name of traffic light.
Definition: NIVisumTL.h:176
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition: NIVisumTL.h:164
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:50
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:118
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition: NIVisumTL.h:185
Represents a single node (junction) during network building.
Definition: NBNode.h:74
std::map< std::string, Phase * > myPhases
Map of used phases if phases defined.
Definition: NIVisumTL.h:194
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition: NIVisumTL.h:191
long long int SUMOTime
Definition: TraCIDefs.h:51
~Phase()
Destructor.
Definition: NIVisumTL.h:99
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:131