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