Eclipse 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-2019 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 /****************************************************************************/
14 // Intermediate class for storing visum traffic lights during their import
15 /****************************************************************************/
16 #ifndef NIVisumTL_h
17 #define NIVisumTL_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <vector>
26 #include <map>
27 #include <string>
29 #include <netbuild/NBNodeCont.h>
30 #include <utils/common/SUMOTime.h>
31 
33 class NBEdgeCont;
34 
35 
36 // ===========================================================================
37 // class declaration
38 // ===========================================================================
43 class NIVisumTL {
44 public:
48  class TimePeriod {
49  public:
51  TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
52  : myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}
53 
56 
59  return myStartTime;
60  }
61 
64  return myEndTime;
65  }
66 
69  return myYellowTime;
70  }
71 
72  private:
79  };
80 
81 
82 
86  class Phase : public TimePeriod {
87  public:
89  Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}
90 
92  ~Phase() {}
93 
94  };
95 
96 
97 
101  class SignalGroup : public TimePeriod {
102  public:
104  SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
105  : NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}
106 
109 
112  return myConnections;
113  }
114 
116  std::map<std::string, Phase*>& phases() {
117  return myPhases;
118  }
119 
120  private:
124  std::map<std::string, Phase*> myPhases;
126  std::string myName;
127  };
128 
129 
130 
131 public:
139  NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,
140  bool phaseDefined);
141 
143  ~NIVisumTL();
144 
146  void addNode(NBNode* n) {
147  myNodes.push_back(n);
148  }
149 
151  void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
152 
154  void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
155 
157  std::map<std::string, Phase*>& getPhases() {
158  return myPhases;
159  }
160 
162  SignalGroup& getSignalGroup(const std::string& name);
163 
165  void build(NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
166 
167 private:
169  std::string myName;
170 
173 
176 
179 
182 
184  std::vector<NBNode*> myNodes;
185 
187  std::map<std::string, Phase*> myPhases;
188 
190  std::map<std::string, SignalGroup*> mySignalGroups;
191 
192 
193 };
194 
195 
196 #endif
197 
198 /****************************************************************************/
199 
NBConnectionDefs.h
NIVisumTL::myCycleTime
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition: NIVisumTL.h:172
NIVisumTL::SignalGroup::myName
std::string myName
name
Definition: NIVisumTL.h:126
SUMOTime.h
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:60
NIVisumTL::myNodes
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition: NIVisumTL.h:184
NIVisumTL::getSignalGroup
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition: NIVisumTL.cpp:67
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
NIVisumTL::Phase::Phase
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:89
NIVisumTL::SignalGroup::~SignalGroup
~SignalGroup()
destructor
Definition: NIVisumTL.h:108
NIVisumTL::Phase::~Phase
~Phase()
Destructor.
Definition: NIVisumTL.h:92
NIVisumTL::~NIVisumTL
~NIVisumTL()
Destructor.
Definition: NIVisumTL.cpp:44
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
NIVisumTL::TimePeriod::getStartTime
SUMOTime getStartTime()
Returns the stored start time.
Definition: NIVisumTL.h:58
NIVisumTL::TimePeriod::myYellowTime
SUMOTime myYellowTime
Yellow time.
Definition: NIVisumTL.h:78
NIVisumTL::addSignalGroup
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:55
NIVisumTL::TimePeriod::getYellowTime
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition: NIVisumTL.h:68
NIVisumTL::TimePeriod::myEndTime
SUMOTime myEndTime
End time.
Definition: NIVisumTL.h:76
NIVisumTL::SignalGroup
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:101
NIVisumTL::TimePeriod::myStartTime
SUMOTime myStartTime
Start time.
Definition: NIVisumTL.h:74
NIVisumTL::SignalGroup::connections
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:111
NIVisumTL::addNode
void addNode(NBNode *n)
Adds a node to control.
Definition: NIVisumTL.h:146
NIVisumTL::myPhaseDefined
bool myPhaseDefined
Toogles the usage either of phases or of time periods in signal groups.
Definition: NIVisumTL.h:181
NIVisumTL::myOffset
SUMOTime myOffset
The offset in the plan.
Definition: NIVisumTL.h:175
NIVisumTL::TimePeriod
A time period with a start and an end time.
Definition: NIVisumTL.h:48
NIVisumTL
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:43
NIVisumTL::addPhase
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition: NIVisumTL.cpp:61
NIVisumTL::myIntermediateTime
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition: NIVisumTL.h:178
NIVisumTL::getPhases
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition: NIVisumTL.h:157
NBNodeCont.h
NIVisumTL::SignalGroup::myPhases
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:124
NIVisumTL::Phase
A phase.
Definition: NIVisumTL.h:86
NIVisumTL::NIVisumTL
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:37
NIVisumTL::SignalGroup::myConnections
NBConnectionVector myConnections
Connections.
Definition: NIVisumTL.h:122
NBConnectionVector
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
Definition: NBConnectionDefs.h:34
NIVisumTL::TimePeriod::~TimePeriod
~TimePeriod()
Destructor.
Definition: NIVisumTL.h:55
NIVisumTL::SignalGroup::SignalGroup
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:104
config.h
NIVisumTL::mySignalGroups
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition: NIVisumTL.h:190
NIVisumTL::myName
std::string myName
The name of traffic light.
Definition: NIVisumTL.h:169
NIVisumTL::SignalGroup::phases
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:116
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
NIVisumTL::TimePeriod::TimePeriod
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:51
NIVisumTL::TimePeriod::getEndTime
SUMOTime getEndTime()
Returns the stored end time.
Definition: NIVisumTL.h:63
NIVisumTL::build
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:73
NIVisumTL::myPhases
std::map< std::string, Phase * > myPhases
Map of used phases if phases defined.
Definition: NIVisumTL.h:187