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 /****************************************************************************/
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 
NBConnectionDefs.h
NIVisumTL::myCycleTime
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition: NIVisumTL.h:173
NIVisumTL::SignalGroup::myName
std::string myName
name
Definition: NIVisumTL.h:127
SUMOTime.h
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
NIVisumTL::myNodes
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition: NIVisumTL.h:185
NIVisumTL::getSignalGroup
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition: NIVisumTL.cpp:68
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:58
NIVisumTL::Phase::Phase
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:90
NIVisumTL::SignalGroup::~SignalGroup
~SignalGroup()
destructor
Definition: NIVisumTL.h:109
NIVisumTL::Phase::~Phase
~Phase()
Destructor.
Definition: NIVisumTL.h:93
NIVisumTL::~NIVisumTL
~NIVisumTL()
Destructor.
Definition: NIVisumTL.cpp:45
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
NIVisumTL::TimePeriod::getStartTime
SUMOTime getStartTime()
Returns the stored start time.
Definition: NIVisumTL.h:59
NIVisumTL::TimePeriod::myYellowTime
SUMOTime myYellowTime
Yellow time.
Definition: NIVisumTL.h:79
NIVisumTL::addSignalGroup
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:56
NIVisumTL::TimePeriod::getYellowTime
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition: NIVisumTL.h:69
NIVisumTL::TimePeriod::myEndTime
SUMOTime myEndTime
End time.
Definition: NIVisumTL.h:77
NIVisumTL::SignalGroup
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:102
NIVisumTL::TimePeriod::myStartTime
SUMOTime myStartTime
Start time.
Definition: NIVisumTL.h:75
NIVisumTL::SignalGroup::connections
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:112
NIVisumTL::addNode
void addNode(NBNode *n)
Adds a node to control.
Definition: NIVisumTL.h:147
NIVisumTL::myPhaseDefined
bool myPhaseDefined
Toogles the usage either of phases or of time periods in signal groups.
Definition: NIVisumTL.h:182
NIVisumTL::myOffset
SUMOTime myOffset
The offset in the plan.
Definition: NIVisumTL.h:176
NIVisumTL::TimePeriod
A time period with a start and an end time.
Definition: NIVisumTL.h:49
NIVisumTL
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:44
NIVisumTL::addPhase
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition: NIVisumTL.cpp:62
NIVisumTL::myIntermediateTime
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition: NIVisumTL.h:179
NIVisumTL::getPhases
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition: NIVisumTL.h:158
NBNodeCont.h
NIVisumTL::SignalGroup::myPhases
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:125
NIVisumTL::Phase
A phase.
Definition: NIVisumTL.h:87
NIVisumTL::NIVisumTL
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:38
NIVisumTL::SignalGroup::myConnections
NBConnectionVector myConnections
Connections.
Definition: NIVisumTL.h:123
NBConnectionVector
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
Definition: NBConnectionDefs.h:35
NIVisumTL::TimePeriod::~TimePeriod
~TimePeriod()
Destructor.
Definition: NIVisumTL.h:56
NIVisumTL::SignalGroup::SignalGroup
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:105
config.h
NIVisumTL::mySignalGroups
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition: NIVisumTL.h:191
NIVisumTL::myName
std::string myName
The name of traffic light.
Definition: NIVisumTL.h:170
NIVisumTL::SignalGroup::phases
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:117
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:68
NIVisumTL::TimePeriod::TimePeriod
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:52
NIVisumTL::TimePeriod::getEndTime
SUMOTime getEndTime()
Returns the stored end time.
Definition: NIVisumTL.h:64
NIVisumTL::build
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:74
NIVisumTL::myPhases
std::map< std::string, Phase * > myPhases
Map of used phases if phases defined.
Definition: NIVisumTL.h:188