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
NBTrafficLightLogic.h
Go to the documentation of this file.
1
/****************************************************************************/
9
// A SUMO-compliant built logic for a traffic light
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
#ifndef NBTrafficLightLogic_h
23
#define NBTrafficLightLogic_h
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#ifdef _MSC_VER
30
#include <
windows_config.h
>
31
#else
32
#include <
config.h
>
33
#endif
34
35
#include <vector>
36
#include <string>
37
#include <bitset>
38
#include <utility>
39
#include <set>
40
#include "
NBConnectionDefs.h
"
41
#include <
utils/common/SUMOTime.h
>
42
#include <
utils/common/Named.h
>
43
44
45
// ===========================================================================
46
// class declarations
47
// ===========================================================================
48
class
OutputDevice
;
49
50
51
// ===========================================================================
52
// class definitions
53
// ===========================================================================
58
class
NBTrafficLightLogic
:
public
Named
{
59
public
:
64
class
PhaseDefinition
{
65
public
:
67
SUMOTime
duration
;
68
70
std::string
state
;
71
76
PhaseDefinition
(
SUMOTime
durationArg,
const
std::string& stateArg)
77
:
duration
(durationArg),
state
(stateArg) { }
78
80
~PhaseDefinition
() { }
81
86
bool
operator!=
(
const
PhaseDefinition
& pd)
const
{
87
return
pd.
duration
!=
duration
|| pd.
state
!=
state
;
88
}
89
90
};
91
92
100
NBTrafficLightLogic
(
const
std::string&
id
,
const
std::string& subid,
unsigned
int
noLinks,
101
SUMOTime
offset = 0,
TrafficLightType
type =
TLTYPE_STATIC
);
102
103
107
NBTrafficLightLogic
(
const
NBTrafficLightLogic
* logic);
108
109
111
~NBTrafficLightLogic
();
112
113
122
void
addStep
(
SUMOTime
duration,
const
std::string& state,
int
index = -1);
123
124
130
void
setPhaseState
(
unsigned
int
phaseIndex,
unsigned
int
tlIndex,
LinkState
linkState);
131
136
void
setPhaseDuration
(
unsigned
int
phaseIndex,
SUMOTime
duration);
137
138
/* @brief deletes the phase at the given index
139
* @note thhrows InvalidArgument on out-of range index
140
*/
141
void
deletePhase
(
unsigned
int
index);
142
143
/* @brief deletes all phases and reset the expect number of links
144
*/
145
void
resetPhases
();
146
151
void
closeBuilding
();
152
153
157
SUMOTime
getDuration
()
const
;
158
159
163
void
setOffset
(
SUMOTime
offset) {
164
myOffset
= offset;
165
}
166
167
171
const
std::string&
getProgramID
()
const
{
172
return
mySubID
;
173
};
174
175
179
const
std::vector<PhaseDefinition>&
getPhases
()
const
{
180
return
myPhases
;
181
}
182
183
187
SUMOTime
getOffset
()
const
{
188
return
myOffset
;
189
};
190
191
194
unsigned
int
getNumLinks
() {
195
return
myNumLinks
;
196
}
197
199
TrafficLightType
getType
()
const
{
200
return
myType
;
201
}
202
204
void
setType
(
TrafficLightType
type) {
205
myType
= type;
206
}
207
208
private
:
210
unsigned
int
myNumLinks
;
211
213
const
std::string
mySubID
;
214
216
SUMOTime
myOffset
;
217
219
typedef
std::vector<PhaseDefinition>
PhaseDefinitionVector
;
220
222
PhaseDefinitionVector
myPhases
;
223
225
TrafficLightType
myType
;
226
228
static
const
char
allowedStatesInitializer
[];
229
static
const
std::string
ALLOWED_STATES
;
230
231
private
:
233
NBTrafficLightLogic
&
operator=
(
const
NBTrafficLightLogic
& s);
234
235
};
236
237
238
#endif
239
240
/****************************************************************************/
241
build
buildd
sumo-0.18~dfsg
src
netbuild
NBTrafficLightLogic.h
Generated on Wed Oct 23 2013 01:15:10 for SUMO - Simulation of Urban MObility by
1.8.4