SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NBLoadedTLDef.h
Go to the documentation of this file.
1
/****************************************************************************/
8
// A loaded (complete) traffic light logic
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
#ifndef NBLoadedTLDef_h
22
#define NBLoadedTLDef_h
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <vector>
35
#include <string>
36
#include <set>
37
#include "
NBTrafficLightDefinition.h
"
38
#include "
NBNode.h
"
39
#include <
utils/common/SUMOTime.h
>
40
41
42
// ===========================================================================
43
// class definitions
44
// ===========================================================================
49
class
NBLoadedTLDef
:
public
NBTrafficLightDefinition
{
50
public
:
54
class
SignalGroup
:
public
Named
{
55
public
:
59
SignalGroup
(
const
std::string&
id
);
60
62
~SignalGroup
();
63
67
void
addConnection
(
const
NBConnection
& c);
68
73
void
addPhaseBegin
(
SUMOTime
time,
TLColor
color);
74
79
void
setYellowTimes
(
SUMOTime
tRedYellowe,
SUMOTime
tYellow);
80
85
std::vector<SUMOReal>
getTimes
(
SUMOTime
cycleDuration)
const
;
86
88
void
sortPhases
();
89
93
unsigned
int
getLinkNo
()
const
;
94
99
bool
mayDrive
(
SUMOTime
time)
const
;
100
105
bool
hasYellow
(
SUMOTime
time)
const
;
106
112
bool
containsConnection
(
NBEdge
* from,
NBEdge
* to)
const
;
113
118
bool
containsIncoming
(
NBEdge
* from)
const
;
119
124
void
remapIncoming
(
NBEdge
* which,
const
EdgeVector
& by);
125
130
bool
containsOutgoing
(
NBEdge
* to)
const
;
131
136
void
remapOutgoing
(
NBEdge
* which,
const
EdgeVector
& by);
137
142
const
NBConnection
&
getConnection
(
unsigned
int
pos)
const
;
143
148
void
patchTYellow
(
SUMOTime
tyellow,
bool
forced);
149
156
void
remap
(
NBEdge
* removed,
int
removedLane,
NBEdge
* by,
int
byLane);
157
161
class
PhaseDef
{
162
public
:
167
PhaseDef
(
SUMOTime
time,
TLColor
color)
168
:
myTime
(time),
myColor
(color) { }
169
171
SUMOTime
myTime
;
173
TLColor
myColor
;
174
};
175
179
class
phase_by_time_sorter
{
180
public
:
182
explicit
phase_by_time_sorter
() { }
183
188
int
operator()
(
const
PhaseDef
& p1,
const
PhaseDef
& p2) {
189
return
p1.
myTime
< p2.
myTime
;
190
}
191
};
192
193
private
:
195
NBConnectionVector
myConnections
;
197
std::vector<PhaseDef>
myPhases
;
199
SUMOTime
myTRedYellow
,
myTYellow
;
200
};
201
202
203
205
typedef
std::map<std::string, SignalGroup*>
SignalGroupCont
;
206
207
213
NBLoadedTLDef
(
const
std::string&
id
,
214
const
std::vector<NBNode*>& junctions,
SUMOTime
offset);
215
216
222
NBLoadedTLDef
(
const
std::string&
id
,
NBNode
* junction,
SUMOTime
offset);
223
224
229
NBLoadedTLDef
(
const
std::string&
id
,
SUMOTime
offset);
230
231
233
~NBLoadedTLDef
();
234
235
241
SignalGroup
*
findGroup
(
NBEdge
* from,
NBEdge
* to)
const
;
242
243
247
void
setCycleDuration
(
unsigned
int
cycleDur);
248
249
253
void
addSignalGroup
(
const
std::string&
id
);
254
255
260
bool
addToSignalGroup
(
const
std::string& groupid,
261
const
NBConnection
& connection);
262
263
268
bool
addToSignalGroup
(
const
std::string& groupid,
269
const
NBConnectionVector
& connections);
270
271
277
void
addSignalGroupPhaseBegin
(
const
std::string& groupid,
278
SUMOTime
time,
TLColor
color);
279
280
286
void
setSignalYellowTimes
(
const
std::string& groupid,
287
SUMOTime
tRedYellow,
SUMOTime
tYellow);
288
289
292
297
void
setTLControllingInformation
(
const
NBEdgeCont
& ec)
const
;
298
299
306
void
remapRemoved
(
NBEdge
* removed,
307
const
EdgeVector
& incoming,
const
EdgeVector
& outgoing);
309
310
311
protected
:
314
321
NBTrafficLightLogic
*
myCompute
(
const
NBEdgeCont
& ec,
322
unsigned
int
brakingTime);
323
324
328
void
collectNodes
();
329
330
335
void
collectLinks
();
336
337
345
bool
mustBrake
(
const
NBEdgeCont
& ec,
346
const
NBConnection
& possProhibited,
347
const
std::string& state,
348
unsigned
int
strmpos)
const
;
349
350
358
void
replaceRemoved
(
NBEdge
* removed,
int
removedLane,
359
NBEdge
* by,
int
byLane);
361
362
private
:
368
std::string
buildPhaseState
(
const
NBEdgeCont
& ec,
unsigned
int
time)
const
;
369
370
371
private
:
373
SignalGroupCont
mySignalGroups
;
374
376
unsigned
int
myCycleDuration
;
377
378
379
};
380
381
382
#endif
383
384
/****************************************************************************/
385
build
buildd
sumo-0.16.0~dfsg
src
netbuild
NBLoadedTLDef.h
Generated on Tue Apr 16 2013 01:32:18 for SUMO - Simulation of Urban MObility by
1.8.3.1