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
MSOffTrafficLightLogic.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A traffic lights logic which represents a tls in an off-mode
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
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
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <utility>
32
#include <vector>
33
#include <bitset>
34
#include <sstream>
35
#include <
microsim/MSEventControl.h
>
36
#include "
MSTrafficLightLogic.h
"
37
#include "
MSOffTrafficLightLogic.h
"
38
39
#ifdef CHECK_MEMORY_LEAKS
40
#include <
foreign/nvwa/debug_new.h
>
41
#endif // CHECK_MEMORY_LEAKS
42
43
44
// ===========================================================================
45
// member method definitions
46
// ===========================================================================
47
MSOffTrafficLightLogic::MSOffTrafficLightLogic
(
MSTLLogicControl
& tlcontrol,
48
const
std::string&
id
) :
49
MSTrafficLightLogic
(tlcontrol, id,
"off"
, 0,
ParameterMap
()) {
50
myDefaultCycleTime
=
TIME2STEPS
(120);
51
}
52
53
54
MSOffTrafficLightLogic::~MSOffTrafficLightLogic
() {
55
for
(MSTrafficLightLogic::Phases::const_iterator i =
myPhaseDefinition
.begin(); i !=
myPhaseDefinition
.end(); ++i) {
56
delete
*i;
57
}
58
}
59
60
61
void
62
MSOffTrafficLightLogic::init
(
NLDetectorBuilder
&) {
63
rebuildPhase
();
64
}
65
66
67
// ----------- Handling of controlled links
68
void
69
MSOffTrafficLightLogic::adaptLinkInformationFrom
(
const
MSTrafficLightLogic
& logic) {
70
MSTrafficLightLogic::adaptLinkInformationFrom
(logic);
71
rebuildPhase
();
72
}
73
74
75
void
76
MSOffTrafficLightLogic::rebuildPhase
() {
77
size_t
no =
getLinks
().size();
78
std::string state;
79
for
(
unsigned
int
i = 0; i < no; ++i) {
80
// !!! no brake mask!
81
state +=
'o'
;
82
}
83
for
(MSTrafficLightLogic::Phases::const_iterator i =
myPhaseDefinition
.begin(); i !=
myPhaseDefinition
.end(); ++i) {
84
delete
*i;
85
}
86
myPhaseDefinition
.clear();
87
myPhaseDefinition
.push_back(
new
MSPhaseDefinition
(
TIME2STEPS
(120), state));
88
}
89
90
91
// ------------ Static Information Retrieval
92
unsigned
int
93
MSOffTrafficLightLogic::getPhaseNumber
()
const
{
94
return
0;
95
}
96
97
98
const
MSOffTrafficLightLogic::Phases
&
99
MSOffTrafficLightLogic::getPhases
()
const
{
100
return
myPhaseDefinition
;
101
}
102
103
104
const
MSPhaseDefinition
&
105
MSOffTrafficLightLogic::getPhase
(
unsigned
int
)
const
{
106
return
*
myPhaseDefinition
[0];
107
}
108
109
110
// ------------ Dynamic Information Retrieval
111
unsigned
int
112
MSOffTrafficLightLogic::getCurrentPhaseIndex
()
const
{
113
return
0;
114
}
115
116
117
const
MSPhaseDefinition
&
118
MSOffTrafficLightLogic::getCurrentPhaseDef
()
const
{
119
return
*
myPhaseDefinition
[0];
120
}
121
122
123
// ------------ Conversion between time and phase
124
SUMOTime
125
MSOffTrafficLightLogic::getPhaseIndexAtTime
(
SUMOTime
)
const
{
126
return
0;
127
}
128
129
130
SUMOTime
131
MSOffTrafficLightLogic::getOffsetFromIndex
(
unsigned
int
)
const
{
132
return
0;
133
}
134
135
136
unsigned
int
137
MSOffTrafficLightLogic::getIndexFromOffset
(
SUMOTime
)
const
{
138
return
0;
139
}
140
141
142
143
/****************************************************************************/
144
build
buildd
sumo-0.17.1~dfsg
src
microsim
traffic_lights
MSOffTrafficLightLogic.cpp
Generated on Sun Jun 16 2013 17:30:16 for SUMO - Simulation of Urban MObility by
1.8.3.1