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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Intermediate class for storing visum traffic lights during their import
16 /****************************************************************************/
17 #ifndef NIVisumTL_h
18 #define NIVisumTL_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <map>
28 #include <string>
30 #include <netbuild/NBNodeCont.h>
31 #include <utils/common/SUMOTime.h>
32 
34 class NBEdgeCont;
35 
36 
37 // ===========================================================================
38 // class declaration
39 // ===========================================================================
44 class NIVisumTL {
45 public:
49  class TimePeriod {
50  public:
52  TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
53  : myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}
54 
57 
60  return myStartTime;
61  }
62 
65  return myEndTime;
66  }
67 
70  return myYellowTime;
71  }
72 
73  private:
80  };
81 
82 
83 
87  class Phase : public TimePeriod {
88  public:
90  Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}
91 
93  ~Phase() {}
94 
95  };
96 
97 
98 
102  class SignalGroup : public TimePeriod {
103  public:
105  SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
106  : NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}
107 
110 
113  return myConnections;
114  }
115 
117  std::map<std::string, Phase*>& phases() {
118  return myPhases;
119  }
120 
121  private:
125  std::map<std::string, Phase*> myPhases;
127  std::string myName;
128  };
129 
130 
131 
132 public:
140  NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,
141  bool phaseDefined);
142 
144  ~NIVisumTL();
145 
147  void addNode(NBNode* n) {
148  myNodes.push_back(n);
149  }
150 
152  void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
153 
155  void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
156 
158  std::map<std::string, Phase*>& getPhases() {
159  return myPhases;
160  }
161 
163  SignalGroup& getSignalGroup(const std::string& name);
164 
166  void build(NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
167 
168 private:
170  std::string myName;
171 
174 
177 
180 
183 
185  std::vector<NBNode*> myNodes;
186 
188  std::map<std::string, Phase*> myPhases;
189 
191  std::map<std::string, SignalGroup*> mySignalGroups;
192 
193 
194 };
195 
196 
197 #endif
198 
199 /****************************************************************************/
200 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:117
bool myPhaseDefined
Toogles the usage either of phases or of time periods in signal groups.
Definition: NIVisumTL.h:182
~SignalGroup()
destructor
Definition: NIVisumTL.h:109
SUMOTime myYellowTime
Yellow time.
Definition: NIVisumTL.h:79
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:102
long long int SUMOTime
Definition: SUMOTime.h:36
A time period with a start and an end time.
Definition: NIVisumTL.h:49
NBConnectionVector myConnections
Connections.
Definition: NIVisumTL.h:123
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition: NIVisumTL.h:69
A container for traffic light definitions and built programs.
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:90
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition: NIVisumTL.cpp:68
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:52
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition: NIVisumTL.h:173
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition: NIVisumTL.cpp:62
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:56
A phase.
Definition: NIVisumTL.h:87
SUMOTime myEndTime
End time.
Definition: NIVisumTL.h:77
SUMOTime getEndTime()
Returns the stored end time.
Definition: NIVisumTL.h:64
~TimePeriod()
Destructor.
Definition: NIVisumTL.h:56
~NIVisumTL()
Destructor.
Definition: NIVisumTL.cpp:45
SUMOTime getStartTime()
Returns the stored start time.
Definition: NIVisumTL.h:59
std::string myName
name
Definition: NIVisumTL.h:127
SUMOTime myOffset
The offset in the plan.
Definition: NIVisumTL.h:176
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:74
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:38
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:105
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
SUMOTime myStartTime
Start time.
Definition: NIVisumTL.h:75
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition: NIVisumTL.h:191
void addNode(NBNode *n)
Adds a node to control.
Definition: NIVisumTL.h:147
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
std::string myName
The name of traffic light.
Definition: NIVisumTL.h:170
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition: NIVisumTL.h:158
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:44
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:112
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition: NIVisumTL.h:179
Represents a single node (junction) during network building.
Definition: NBNode.h:68
std::map< std::string, Phase * > myPhases
Map of used phases if phases defined.
Definition: NIVisumTL.h:188
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition: NIVisumTL.h:185
~Phase()
Destructor.
Definition: NIVisumTL.h:93
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:125