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-sim.org/
11
// Copyright (C) 2001-2014 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
214
NBLoadedTLDef
(
const
std::string&
id
,
215
const
std::vector<NBNode*>& junctions,
SUMOTime
offset,
216
TrafficLightType
type);
217
218
225
NBLoadedTLDef
(
const
std::string&
id
,
NBNode
* junction,
SUMOTime
offset,
226
TrafficLightType
type);
227
228
234
NBLoadedTLDef
(
const
std::string&
id
,
SUMOTime
offset,
235
TrafficLightType
type);
236
237
239
~NBLoadedTLDef
();
240
241
247
SignalGroup
*
findGroup
(
NBEdge
* from,
NBEdge
* to)
const
;
248
249
253
void
setCycleDuration
(
unsigned
int
cycleDur);
254
255
259
void
addSignalGroup
(
const
std::string&
id
);
260
261
266
bool
addToSignalGroup
(
const
std::string& groupid,
267
const
NBConnection
& connection);
268
269
274
bool
addToSignalGroup
(
const
std::string& groupid,
275
const
NBConnectionVector
& connections);
276
277
283
void
addSignalGroupPhaseBegin
(
const
std::string& groupid,
284
SUMOTime
time,
TLColor
color);
285
286
292
void
setSignalYellowTimes
(
const
std::string& groupid,
293
SUMOTime
tRedYellow,
SUMOTime
tYellow);
294
295
298
303
void
setTLControllingInformation
(
const
NBEdgeCont
& ec)
const
;
304
305
312
void
remapRemoved
(
NBEdge
* removed,
313
const
EdgeVector
& incoming,
const
EdgeVector
& outgoing);
315
316
317
protected
:
320
327
NBTrafficLightLogic
*
myCompute
(
const
NBEdgeCont
& ec,
328
unsigned
int
brakingTime);
329
330
334
void
collectNodes
();
335
336
341
void
collectLinks
();
342
343
351
bool
mustBrake
(
const
NBEdgeCont
& ec,
352
const
NBConnection
& possProhibited,
353
const
std::string& state,
354
unsigned
int
strmpos)
const
;
355
356
364
void
replaceRemoved
(
NBEdge
* removed,
int
removedLane,
365
NBEdge
* by,
int
byLane);
367
368
private
:
374
std::string
buildPhaseState
(
const
NBEdgeCont
& ec,
unsigned
int
time)
const
;
375
376
377
private
:
379
SignalGroupCont
mySignalGroups
;
380
382
unsigned
int
myCycleDuration
;
383
384
385
};
386
387
388
#endif
389
390
/****************************************************************************/
391
tmp
buildd
sumo-0.21.0+dfsg
src
netbuild
NBLoadedTLDef.h
Generated on Thu Nov 20 2014 19:49:56 for SUMO - Simulation of Urban MObility by
1.8.1.2