Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIVisumTL.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Intermediate class for storing visum traffic lights during their import
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <vector>
24#include <map>
25#include <string>
27#include <netbuild/NBNodeCont.h>
29
31class NBEdgeCont;
32
33
34// ===========================================================================
35// class declaration
36// ===========================================================================
41class NIVisumTL {
42public:
46 class TimePeriod {
47 public:
49 TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
50 : myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}
51
54
57 return myStartTime;
58 }
59
62 return myEndTime;
63 }
64
67 return myYellowTime;
68 }
69
70 private:
77
78 private:
80 TimePeriod& operator=(const TimePeriod& s) = delete;
81 };
82
83
84
88 class Phase : public TimePeriod {
89 public:
91 Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}
92
94 ~Phase() {}
95
96 };
97
98
99
103 class SignalGroup : public TimePeriod {
104 public:
106 SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
107 : NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}
108
111
116
118 std::map<std::string, Phase*>& phases() {
119 return myPhases;
120 }
121
122 private:
126 std::map<std::string, Phase*> myPhases;
128 std::string myName;
129 };
130
131
132
133public:
141 NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,
142 bool phaseDefined);
143
145 ~NIVisumTL();
146
148 void addNode(NBNode* n) {
149 myNodes.push_back(n);
150 }
151
153 void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
154
156 void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);
157
159 std::map<std::string, Phase*>& getPhases() {
160 return myPhases;
161 }
162
164 SignalGroup& getSignalGroup(const std::string& name);
165
168
169private:
171 std::string myName;
172
175
178
181
184
186 std::vector<NBNode*> myNodes;
187
189 std::map<std::string, Phase*> myPhases;
190
192 std::map<std::string, SignalGroup*> mySignalGroups;
193
194
195};
long long int SUMOTime
Definition GUI.h:36
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
Represents a single node (junction) during network building.
Definition NBNode.h:66
A container for traffic light definitions and built programs.
~Phase()
Destructor.
Definition NIVisumTL.h:94
Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition NIVisumTL.h:91
A signal group can be defined either by a time period or by phases.
Definition NIVisumTL.h:103
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition NIVisumTL.h:118
std::string myName
name
Definition NIVisumTL.h:128
std::map< std::string, Phase * > myPhases
phases
Definition NIVisumTL.h:126
NBConnectionVector & connections()
Returns the connections vector.
Definition NIVisumTL.h:113
SignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
constructor
Definition NIVisumTL.h:106
~SignalGroup()
destructor
Definition NIVisumTL.h:110
NBConnectionVector myConnections
Connections.
Definition NIVisumTL.h:124
A time period with a start and an end time.
Definition NIVisumTL.h:46
SUMOTime getYellowTime()
Returns the stored yellow time.
Definition NIVisumTL.h:66
const SUMOTime myStartTime
Start time.
Definition NIVisumTL.h:72
const SUMOTime myEndTime
End time.
Definition NIVisumTL.h:74
const SUMOTime myYellowTime
Yellow time.
Definition NIVisumTL.h:76
SUMOTime getStartTime()
Returns the stored start time.
Definition NIVisumTL.h:56
TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Constructor.
Definition NIVisumTL.h:49
TimePeriod & operator=(const TimePeriod &s)=delete
Invalidated assignment operator.
~TimePeriod()
Destructor.
Definition NIVisumTL.h:53
SUMOTime getEndTime()
Returns the stored end time.
Definition NIVisumTL.h:61
Intermediate class for storing visum traffic lights during their import.
Definition NIVisumTL.h:41
void addNode(NBNode *n)
Adds a node to control.
Definition NIVisumTL.h:148
SUMOTime myOffset
The offset in the plan.
Definition NIVisumTL.h:177
std::map< std::string, Phase * > & getPhases()
Returns the map of named phases.
Definition NIVisumTL.h:159
bool myPhaseDefined
Toggles the usage either of phases or of time periods in signal groups.
Definition NIVisumTL.h:183
void addSignalGroup(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a signal group.
Definition NIVisumTL.cpp:54
SUMOTime myCycleTime
The cycle time of traffic light in seconds.
Definition NIVisumTL.h:174
std::map< std::string, SignalGroup * > mySignalGroups
Map of used signal groups.
Definition NIVisumTL.h:192
std::string myName
The name of traffic light.
Definition NIVisumTL.h:171
void addPhase(const std::string &name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)
Adds a phase.
Definition NIVisumTL.cpp:60
std::vector< NBNode * > myNodes
Vector of nodes belonging to this traffic light.
Definition NIVisumTL.h:186
std::map< std::string, Phase * > myPhases
Map of used phases if phases defined.
Definition NIVisumTL.h:189
SignalGroup & getSignalGroup(const std::string &name)
Returns the named signal group.
Definition NIVisumTL.cpp:66
SUMOTime myIntermediateTime
The all-red time (unused here)
Definition NIVisumTL.h:180
void build(NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
build the traffic light and add it to the given container
Definition NIVisumTL.cpp:72
~NIVisumTL()
Destructor.
Definition NIVisumTL.cpp:43