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
MSLink.h
Go to the documentation of this file.
1
/****************************************************************************/
9
// A connnection between lanes
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
#ifndef MSLink_h
23
#define MSLink_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 <set>
37
#include <
utils/common/SUMOTime.h
>
38
#include <
utils/xml/SUMOXMLDefinitions.h
>
39
40
41
// ===========================================================================
42
// class declarations
43
// ===========================================================================
44
class
MSLane
;
45
class
SUMOVehicle
;
46
47
48
// ===========================================================================
49
// class definitions
50
// ===========================================================================
71
class
MSLink
{
72
public
:
76
struct
ApproachingVehicleInformation
{
78
ApproachingVehicleInformation
(
const
SUMOTime
_arrivalTime,
const
SUMOTime
_leavingTime,
SUMOVehicle
* _vehicle,
const
bool
_willPass)
79
:
arrivalTime
(_arrivalTime),
leavingTime
(_leavingTime),
vehicle
(_vehicle),
willPass
(_willPass) {}
80
82
SUMOTime
arrivalTime
;
84
SUMOTime
leavingTime
;
86
SUMOVehicle
*
vehicle
;
88
bool
willPass
;
89
};
90
91
92
#ifndef HAVE_INTERNAL_LANES
93
100
MSLink
(
MSLane
* succLane,
LinkDirection
dir,
LinkState
state,
SUMOReal
length);
101
#else
102
110
MSLink
(
MSLane
* succLane,
MSLane
* via,
LinkDirection
dir,
LinkState
state,
SUMOReal
length);
111
#endif
112
113
115
~MSLink
();
116
117
125
void
setRequestInformation
(
unsigned
int
requestIdx,
unsigned
int
respondIdx,
bool
isCrossing
,
bool
isCont
,
126
const
std::vector<MSLink*>& foeLinks,
const
std::vector<MSLane*>& foeLanes);
127
128
133
void
setApproaching
(
SUMOVehicle
* approaching,
SUMOTime
arrivalTime,
SUMOReal
speed,
bool
setRequest);
134
135
136
137
void
addBlockedLink
(
MSLink
* link);
138
139
140
141
void
removeApproaching
(
SUMOVehicle
* veh);
142
const
std::vector<ApproachingVehicleInformation>&
getApproaching
()
const
{
143
return
myApproachingVehicles
;
144
}
145
146
153
bool
opened
(
SUMOTime
arrivalTime,
SUMOReal
arrivalSpeed,
SUMOReal
leaveSpeed,
SUMOReal
vehicleLength)
const
;
154
162
bool
blockedAtTime
(
SUMOTime
arrivalTime,
SUMOTime
leaveTime,
SUMOReal
speed)
const
;
163
164
bool
isBlockingAnyone
()
const
{
165
return
myApproachingVehicles
.size() != 0;
166
}
167
168
bool
willHaveBlockedFoe
()
const
;
169
170
171
180
bool
hasApproachingFoe
(
SUMOTime
arrivalTime,
SUMOTime
leaveTime,
SUMOReal
speed)
const
;
181
182
187
LinkState
getState
()
const
{
188
return
myState
;
189
}
190
191
196
LinkDirection
getDirection
()
const
;
197
198
203
void
setTLState
(
LinkState
state,
SUMOTime
t);
204
205
210
MSLane
*
getLane
()
const
;
211
212
217
unsigned
int
getRespondIndex
()
const
;
218
219
223
bool
havePriority
()
const
{
224
return
myState
>=
'A'
&&
myState
<=
'Z'
;
225
}
226
227
232
SUMOReal
getLength
()
const
{
233
return
myLength
;
234
}
235
240
bool
isCrossing
()
const
{
241
return
myIsCrossing
;
242
}
243
244
245
bool
isCont
()
const
{
246
return
myAmCont
;
247
}
248
249
#ifdef HAVE_INTERNAL_LANES
250
254
MSLane
* getViaLane()
const
;
255
#endif
256
258
MSLane
*
getViaLaneOrLane
()
const
;
259
260
private
:
261
typedef
std::vector<ApproachingVehicleInformation>
LinkApproachingVehicles
;
262
263
class
vehicle_in_request_finder
{
264
public
:
265
explicit
vehicle_in_request_finder
(
const
SUMOVehicle
*
const
v) :
myVehicle
(v) { }
266
bool
operator()
(
const
ApproachingVehicleInformation
& vo) {
267
return
vo.
vehicle
==
myVehicle
;
268
}
269
private
:
270
vehicle_in_request_finder
&
operator=
(
const
vehicle_in_request_finder
&);
// just to avoid a compiler warning
271
private
:
272
const
SUMOVehicle
*
const
myVehicle
;
273
274
};
275
276
static
SUMOTime
safeHeadwayTime
(
SUMOReal
leaderSpeed,
SUMOReal
followerSpeed);
277
278
279
private
:
281
MSLane
*
myLane
;
282
283
LinkApproachingVehicles
myApproachingVehicles
;
284
std::set<MSLink*>
myBlockedFoeLinks
;
285
287
unsigned
int
myRequestIdx
;
288
290
unsigned
int
myRespondIdx
;
291
293
LinkState
myState
;
294
296
LinkDirection
myDirection
;
297
299
SUMOReal
myLength
;
300
302
bool
myIsCrossing
;
303
304
bool
myAmCont
;
305
306
#ifdef HAVE_INTERNAL_LANES
307
308
MSLane
*
const
myJunctionInlane;
309
#endif
310
311
std::vector<MSLink*>
myFoeLinks
;
312
std::vector<MSLane*>
myFoeLanes
;
313
static
SUMOTime
myLookaheadTime
;
314
315
316
private
:
318
MSLink
(
const
MSLink
& s);
319
321
MSLink
&
operator=
(
const
MSLink
& s);
322
323
};
324
325
326
#endif
327
328
/****************************************************************************/
329
build
buildd
sumo-0.16.0~dfsg
src
microsim
MSLink.h
Generated on Tue Apr 16 2013 01:32:17 for SUMO - Simulation of Urban MObility by
1.8.3.1