SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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-sim.org/
10 // Copyright (C) 2001-2013 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 
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(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
void build(NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition: NIVisumTL.cpp:81
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:75
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:69
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition: NIVisumTL.cpp:63
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:52
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
NIVisumTL(const std::string &name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime, bool phaseDefined)
Constructor.
Definition: NIVisumTL.cpp:45
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition: NIVisumTL.h:111
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
int SUMOTime
Definition: SUMOTime.h:43
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
~Phase()
Destructor.
Definition: NIVisumTL.h:99
std::map< std::string, Phase * > myPhases
phases
Definition: NIVisumTL.h:131