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
MSVehicleControl.h
Go to the documentation of this file.
1
/****************************************************************************/
9
// The class responsible for building and deletion of vehicles
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2014 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 MSVehicleControl_h
23
#define MSVehicleControl_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 <math.h>
36
#include <string>
37
#include <map>
38
#include <set>
39
#include "
MSGlobals.h
"
40
#include <
utils/common/RandHelper.h
>
41
#include <
utils/common/SUMOTime.h
>
42
#include <
utils/common/RandomDistributor.h
>
43
#include <
utils/common/SUMOVehicleParameter.h
>
44
45
46
// ===========================================================================
47
// class declarations
48
// ===========================================================================
49
class
SUMOVehicle
;
50
class
MSVehicle
;
51
class
MSRoute
;
52
class
MSVehicleType
;
53
class
BinaryInputDevice
;
54
class
MSEdge
;
55
56
57
// ===========================================================================
58
// class definitions
59
// ===========================================================================
75
class
MSVehicleControl
{
76
public
:
78
typedef
std::map<std::string, SUMOVehicle*>::const_iterator
constVehIt
;
79
80
public
:
82
MSVehicleControl
();
83
84
86
virtual
~MSVehicleControl
();
87
88
91
102
virtual
SUMOVehicle
*
buildVehicle
(
SUMOVehicleParameter
* defs,
const
MSRoute
* route,
103
const
MSVehicleType
* type);
105
106
107
110
123
virtual
bool
addVehicle
(
const
std::string&
id
,
SUMOVehicle
* v);
124
125
134
SUMOVehicle
*
getVehicle
(
const
std::string&
id
)
const
;
135
136
143
virtual
void
deleteVehicle
(
SUMOVehicle
* v,
bool
discard =
false
);
144
145
157
void
scheduleVehicleRemoval
(
SUMOVehicle
* veh);
158
159
164
constVehIt
loadedVehBegin
()
const
;
165
166
171
constVehIt
loadedVehEnd
()
const
;
173
174
175
178
186
void
vehicleDeparted
(
const
SUMOVehicle
& v);
188
189
190
193
197
unsigned
int
getLoadedVehicleNo
()
const
{
198
return
myLoadedVehNo
;
199
}
200
201
205
unsigned
int
getEndedVehicleNo
()
const
{
206
return
myEndedVehNo
;
207
}
208
209
213
unsigned
int
getRunningVehicleNo
()
const
{
214
return
myRunningVehNo
;
215
}
216
217
221
unsigned
int
getDepartedVehicleNo
()
const
{
222
return
myRunningVehNo
+
myEndedVehNo
-
myDiscarded
;
223
}
224
225
232
unsigned
int
getQuota
(
SUMOReal
frac = -1)
const
;
233
234
239
int
getActiveVehicleCount
()
const
{
240
return
myLoadedVehNo
- (
myWaitingForPerson
+
myEndedVehNo
);
241
}
242
243
245
unsigned
int
getCollisionCount
()
const
{
246
return
myCollisions
;
247
}
248
250
unsigned
int
getTeleportsJam
()
const
{
251
return
myTeleportsJam
;
252
}
253
255
unsigned
int
getTeleportsYield
()
const
{
256
return
myTeleportsYield
;
257
}
258
260
unsigned
int
getTeleportsWrongLane
()
const
{
261
return
myTeleportsWrongLane
;
262
}
263
265
unsigned
int
getTeleportCount
()
const
{
266
return
myCollisions
+
myTeleportsJam
+
myTeleportsYield
+
myTeleportsWrongLane
;
267
}
268
270
unsigned
int
getEmergencyStops
()
const
{
271
return
myEmergencyStops
;
272
}
273
274
278
SUMOReal
getTotalDepartureDelay
()
const
{
279
return
myTotalDepartureDelay
;
280
}
281
282
286
SUMOReal
getTotalTravelTime
()
const
{
287
return
myTotalTravelTime
;
288
}
290
291
292
295
308
bool
addVType
(
MSVehicleType
* vehType);
309
310
324
bool
addVTypeDistribution
(
const
std::string&
id
,
RandomDistributor<MSVehicleType*>
* vehTypeDistribution);
325
326
334
bool
hasVTypeDistribution
(
const
std::string&
id
)
const
;
335
336
341
MSVehicleType
*
getVType
(
const
std::string&
id
= DEFAULT_VTYPE_ID);
342
343
347
void
insertVTypeIDs
(std::vector<std::string>& into)
const
;
349
350
void
addWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
351
352
void
removeWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
353
354
SUMOVehicle
*
getWaitingVehicle
(
const
MSEdge
*
const
edge,
const
std::set<std::string>& lines);
355
358
void
registerOneWaitingForPerson
() {
359
myWaitingForPerson
++;
360
}
361
364
void
unregisterOneWaitingForPerson
() {
365
myWaitingForPerson
--;
366
}
367
369
void
registerCollision
() {
370
myCollisions
++;
371
}
372
374
void
registerTeleportJam
() {
375
myTeleportsJam
++;
376
}
377
379
void
registerTeleportYield
() {
380
myTeleportsYield
++;
381
}
382
384
void
registerTeleportWrongLane
() {
385
myTeleportsWrongLane
++;
386
}
387
389
void
registerEmergencyStop
() {
390
myEmergencyStops
++;
391
}
392
395
398
void
setState
(
int
runningVehNo,
int
endedVehNo,
SUMOReal
totalDepartureDelay,
SUMOReal
totalTravelTime);
399
402
void
saveState
(
OutputDevice
& out);
404
405
408
void
abortWaiting
();
409
410
411
public
:
413
static
MTRand
myVehicleParamsRNG
;
414
415
416
private
:
423
bool
checkVType
(
const
std::string&
id
);
424
425
protected
:
428
430
unsigned
int
myLoadedVehNo
;
431
433
unsigned
int
myRunningVehNo
;
434
436
unsigned
int
myEndedVehNo
;
437
439
unsigned
int
myDiscarded
;
440
442
unsigned
int
myCollisions
;
443
445
unsigned
int
myTeleportsJam
;
446
448
unsigned
int
myTeleportsYield
;
449
451
unsigned
int
myTeleportsWrongLane
;
452
454
unsigned
int
myEmergencyStops
;
455
457
458
461
463
SUMOReal
myTotalDepartureDelay
;
464
466
SUMOReal
myTotalTravelTime
;
468
469
472
474
typedef
std::map< std::string, SUMOVehicle* >
VehicleDictType
;
476
VehicleDictType
myVehicleDict
;
478
479
482
484
typedef
std::map< std::string, MSVehicleType* >
VTypeDictType
;
486
VTypeDictType
myVTypeDict
;
487
489
typedef
std::map< std::string, RandomDistributor<MSVehicleType*>* >
VTypeDistDictType
;
491
VTypeDistDictType
myVTypeDistDict
;
492
494
bool
myDefaultVTypeMayBeDeleted
;
495
497
std::map<const MSEdge* const, std::vector<SUMOVehicle*> >
myWaiting
;
498
500
unsigned
int
myWaitingForPerson
;
501
503
SUMOReal
myScale
;
504
506
SUMOTime
myMaxRandomDepartOffset
;
507
508
509
private
:
511
MSVehicleControl
(
const
MSVehicleControl
& s);
512
514
MSVehicleControl
&
operator=
(
const
MSVehicleControl
& s);
515
516
517
};
518
519
520
#endif
521
522
/****************************************************************************/
523
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
MSVehicleControl.h
Generated on Thu Nov 20 2014 19:49:56 for SUMO - Simulation of Urban MObility by
1.8.1.2