SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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.dlr.de/
10 // Copyright (C) 2001-2016 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 class NBEdgeCont;
42 
43 
44 // ===========================================================================
45 // class declaration
46 // ===========================================================================
51 class NIVisumTL {
52 public:
56  class TimePeriod {
57  public:
59  TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
60  : myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}
61 
64 
67  return myStartTime;
68  }
69 
72  return myEndTime;
73  }
74 
77  return myYellowTime;
78  }
79 
80  private:
87  };
88 
89 
90 
94  class Phase : public TimePeriod {
95  public:
97  Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}
98 
100  ~Phase() {}
101 
102  };
103 
104 
105 
109  class SignalGroup : public TimePeriod {
110  public:
112  SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
113  : NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}
114 
117 
120  return myConnections;
121  }
122 
124  std::map<std::string, Phase*>& phases() {
125  return myPhases;
126  }
127 
128  private:
132  std::map<std::string, Phase*> myPhases;
134  std::string myName;
135  };
136 
137 
138 
139 public:
147  NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,
148  bool phaseDefined);
149 
151  ~NIVisumTL();
152 
154  void addNode(NBNode* n) {
155  myNodes.push_back(n);
156  }
157 
159  void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
160 
162  void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
163 
165  std::map<std::string, Phase*>& getPhases() {
166  return myPhases;
167  }
168 
170  SignalGroup& getSignalGroup(const std::string& name);
171 
173  void build(NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
174 
175 private:
177  std::string myName;
178 
181 
184 
187 
190 
192  std::vector<NBNode*> myNodes;
193 
195  std::map<std::string, Phase*> myPhases;
196 
198  std::map<std::string, SignalGroup*> mySignalGroups;
199 
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
207 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:124
bool myPhaseDefined
Toogles the usage either of phases or of time periods in signal groups.
Definition: NIVisumTL.h:189
~SignalGroup()
destructor
Definition: NIVisumTL.h:116
SUMOTime myYellowTime
Yellow time.
Definition: NIVisumTL.h:86
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:109
long long int SUMOTime
Definition: SUMOTime.h:43
A time period with a start and an end time.
Definition: NIVisumTL.h:56
NBConnectionVector myConnections
Connections.
Definition: NIVisumTL.h:130
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition: NIVisumTL.h:76
A container for traffic light definitions and built programs.
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:97
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition: NIVisumTL.cpp:78
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition: NIVisumTL.h:59
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition: NIVisumTL.h:180
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition: NIVisumTL.cpp:72
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:66
A phase.
Definition: NIVisumTL.h:94
SUMOTime myEndTime
End time.
Definition: NIVisumTL.h:84
SUMOTime getEndTime()
Returns the stored end time.
Definition: NIVisumTL.h:71
~TimePeriod()
Destructor.
Definition: NIVisumTL.h:63
~NIVisumTL()
Destructor.
Definition: NIVisumTL.cpp:55
SUMOTime getStartTime()
Returns the stored start time.
Definition: NIVisumTL.h:66
std::string myName
name
Definition: NIVisumTL.h:134
SUMOTime myOffset
The offset in the plan.
Definition: NIVisumTL.h:183
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:84
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:48
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:112
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
SUMOTime myStartTime
Start time.
Definition: NIVisumTL.h:82
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition: NIVisumTL.h:198
void addNode(NBNode *n)
Adds a node to control.
Definition: NIVisumTL.h:154
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
std::string myName
The name of traffic light.
Definition: NIVisumTL.h:177
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition: NIVisumTL.h:165
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:51
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:119
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition: NIVisumTL.h:186
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:195
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition: NIVisumTL.h:192
~Phase()
Destructor.
Definition: NIVisumTL.h:100
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:132