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
MSTrafficLightLogic.h
Go to the documentation of this file.
1
/****************************************************************************/
11
// The parent class for traffic light logics
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
15
/****************************************************************************/
16
//
17
// This file is part of SUMO.
18
// SUMO is free software: you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation, either version 3 of the License, or
21
// (at your option) any later version.
22
//
23
/****************************************************************************/
24
#ifndef MSTrafficLightLogic_h
25
#define MSTrafficLightLogic_h
26
27
28
// ===========================================================================
29
// included modules
30
// ===========================================================================
31
#ifdef _MSC_VER
32
#include <
windows_config.h
>
33
#else
34
#include <
config.h
>
35
#endif
36
37
#include <map>
38
#include <string>
39
#include <bitset>
40
#include <
utils/common/Command.h
>
41
#include <
microsim/MSLogicJunction.h
>
42
#include <
microsim/MSLink.h
>
43
#include "
MSPhaseDefinition.h
"
44
45
46
// ===========================================================================
47
// class declarations
48
// ===========================================================================
49
class
MSNet
;
50
class
MSLink
;
51
class
MSTLLogicControl
;
52
class
NLDetectorBuilder
;
53
54
55
// ===========================================================================
56
// class definitions
57
// ===========================================================================
62
class
MSTrafficLightLogic
{
63
public
:
66
68
typedef
std::vector<MSPhaseDefinition*>
Phases
;
69
71
typedef
std::vector<MSLink*>
LinkVector
;
72
74
typedef
std::vector<LinkVector>
LinkVectorVector
;
75
77
typedef
std::vector<MSLane*>
LaneVector
;
78
80
typedef
std::vector<LaneVector>
LaneVectorVector
;
81
82
typedef
std::map<std::string, std::string>
ParameterMap
;
84
85
86
public
:
93
MSTrafficLightLogic
(
MSTLLogicControl
& tlcontrol,
94
const
std::string&
id
,
95
const
std::string& programID,
96
SUMOTime
delay,
97
const
ParameterMap
& parameters);
98
99
105
virtual
void
init
(
NLDetectorBuilder
& nb);
106
107
109
virtual
~MSTrafficLightLogic
();
110
111
112
115
121
void
addLink
(
MSLink
* link,
MSLane
* lane,
unsigned
int
pos);
122
123
131
virtual
void
adaptLinkInformationFrom
(
const
MSTrafficLightLogic
& logic);
132
133
137
std::map<MSLink*, LinkState>
collectLinkStates
()
const
;
138
139
143
void
resetLinkStates
(
const
std::map<MSLink*, LinkState>& vals)
const
;
145
146
147
150
155
virtual
SUMOTime
trySwitch
(
bool
isActive) = 0;
156
157
164
bool
setTrafficLightSignals
(
SUMOTime
t)
const
;
166
167
168
171
175
const
std::string&
getID
()
const
{
176
return
myID
;
177
}
178
179
183
const
std::string&
getProgramID
()
const
{
184
return
myProgramID
;
185
}
186
187
191
const
LaneVectorVector
&
getLanes
()
const
{
192
return
myLanes
;
193
}
194
195
200
const
LaneVector
&
getLanesAt
(
unsigned
int
i)
const
{
201
return
myLanes
[i];
202
}
203
204
208
const
LinkVectorVector
&
getLinks
()
const
{
209
return
myLinks
;
210
}
211
212
217
const
LinkVector
&
getLinksAt
(
unsigned
int
i)
const
{
218
return
myLinks
[i];
219
}
220
221
226
int
getLinkIndex
(
const
MSLink
*
const
link)
const
;
227
228
232
virtual
unsigned
int
getPhaseNumber
()
const
= 0;
233
234
238
virtual
const
Phases
&
getPhases
()
const
= 0;
239
240
245
virtual
const
MSPhaseDefinition
&
getPhase
(
unsigned
int
givenstep)
const
= 0;
247
248
249
252
256
virtual
unsigned
int
getCurrentPhaseIndex
()
const
= 0;
257
258
262
virtual
const
MSPhaseDefinition
&
getCurrentPhaseDef
()
const
= 0;
263
264
268
SUMOTime
getDefaultCycleTime
()
const
{
269
return
myDefaultCycleTime
;
270
}
271
272
278
SUMOTime
getNextSwitchTime
()
const
;
280
281
282
285
289
virtual
SUMOTime
getPhaseIndexAtTime
(
SUMOTime
simStep)
const
= 0;
290
291
296
virtual
SUMOTime
getOffsetFromIndex
(
unsigned
int
index)
const
= 0;
297
298
303
virtual
unsigned
int
getIndexFromOffset
(
SUMOTime
offset)
const
= 0;
305
306
307
310
314
void
addOverridingDuration
(
SUMOTime
duration);
315
316
320
void
setCurrentDurationIncrement
(
SUMOTime
delay);
321
322
329
virtual
void
changeStepAndDuration
(
MSTLLogicControl
& tlcontrol,
330
SUMOTime
simStep,
unsigned
int
step,
SUMOTime
stepDuration) = 0;
331
333
334
335
338
342
void
setParameter
(
const
ParameterMap
& params);
343
344
349
std::string
getParameterValue
(
const
std::string& key)
const
;
351
352
353
protected
:
358
class
SwitchCommand
:
public
Command
{
359
public
:
365
SwitchCommand
(
MSTLLogicControl
& tlcontrol,
366
MSTrafficLightLogic
* tlLogic,
367
SUMOTime
nextSwitch);
368
370
~SwitchCommand
();
371
376
SUMOTime
execute
(
SUMOTime
currentTime);
377
378
382
void
deschedule
(
MSTrafficLightLogic
* tlLogic);
383
384
388
SUMOTime
getNextSwitchTime
()
const
{
389
return
myAssumedNextSwitch
;
390
}
391
392
393
private
:
395
MSTLLogicControl
&
myTLControl
;
396
398
MSTrafficLightLogic
*
myTLLogic
;
399
401
SUMOTime
myAssumedNextSwitch
;
402
404
bool
myAmValid
;
405
406
private
:
408
SwitchCommand
(
const
SwitchCommand
&);
409
411
SwitchCommand
&
operator=
(
const
SwitchCommand
&);
412
413
};
414
415
protected
:
417
ParameterMap
myParameter
;
418
420
std::string
myID
,
myProgramID
;
421
423
LinkVectorVector
myLinks
;
424
426
LaneVectorVector
myLanes
;
427
429
std::vector<SUMOTime>
myOverridingTimes
;
430
432
SUMOTime
myCurrentDurationIncrement
;
433
435
SwitchCommand
*
mySwitchCommand
;
436
438
SUMOTime
myDefaultCycleTime
;
439
440
441
private
:
443
MSTrafficLightLogic
(
const
MSTrafficLightLogic
& s);
444
446
MSTrafficLightLogic
&
operator=
(
const
MSTrafficLightLogic
& s);
447
448
};
449
450
451
#endif
452
453
/****************************************************************************/
454
build
buildd
sumo-0.17.1~dfsg
src
microsim
traffic_lights
MSTrafficLightLogic.h
Generated on Sun Jun 16 2013 17:30:17 for SUMO - Simulation of Urban MObility by
1.8.3.1