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.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
#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
bool
isInQuota
(
SUMOReal
frac = -1)
const
;
233
234
239
int
getActiveVehicleCount
()
const
{
240
return
myLoadedVehNo
- (
myWaitingForPerson
+
myEndedVehNo
);
241
}
242
244
unsigned
int
getCollisionCount
()
const
{
245
return
myCollisions
;
246
}
247
248
250
unsigned
int
getTeleportCount
()
const
{
251
return
myTeleports
;
252
}
254
255
258
263
void
printMeanWaitingTime
(
OutputDevice
& od)
const
;
264
265
270
void
printMeanTravelTime
(
OutputDevice
& od)
const
;
272
273
274
275
278
291
bool
addVType
(
MSVehicleType
* vehType);
292
293
307
bool
addVTypeDistribution
(
const
std::string&
id
,
RandomDistributor<MSVehicleType*>
* vehTypeDistribution);
308
309
317
bool
hasVTypeDistribution
(
const
std::string&
id
)
const
;
318
319
324
MSVehicleType
*
getVType
(
const
std::string&
id
= DEFAULT_VTYPE_ID);
325
326
330
void
insertVTypeIDs
(std::vector<std::string>& into)
const
;
332
333
void
addWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
334
335
void
removeWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
336
337
SUMOVehicle
*
getWaitingVehicle
(
const
MSEdge
*
const
edge,
const
std::set<std::string>& lines);
338
341
void
registerOneWaitingForPerson
() {
342
myWaitingForPerson
++;
343
}
344
347
void
unregisterOneWaitingForPerson
() {
348
myWaitingForPerson
--;
349
}
350
352
void
registerCollision
() {
353
myTeleports
++;
354
myCollisions
++;
355
}
356
358
void
registerTeleport
() {
359
myTeleports
++;
360
}
361
364
367
void
setState
(
int
runningVehNo,
int
endedVehNo,
SUMOReal
totalDepartureDelay,
SUMOReal
totalTravelTime);
368
372
virtual
void
saveState
(
OutputDevice
& out);
374
375
378
void
abortWaiting
();
379
380
381
public
:
383
static
MTRand
myVehicleParamsRNG
;
384
385
386
private
:
393
bool
checkVType
(
const
std::string&
id
);
394
395
396
protected
:
399
401
unsigned
int
myLoadedVehNo
;
402
404
unsigned
int
myRunningVehNo
;
405
407
unsigned
int
myEndedVehNo
;
408
410
unsigned
int
myDiscarded
;
411
413
unsigned
int
myCollisions
;
414
416
unsigned
int
myTeleports
;
418
419
422
424
SUMOReal
myTotalDepartureDelay
;
425
427
SUMOReal
myTotalTravelTime
;
429
430
433
435
typedef
std::map< std::string, SUMOVehicle* >
VehicleDictType
;
437
VehicleDictType
myVehicleDict
;
439
440
443
445
typedef
std::map< std::string, MSVehicleType* >
VTypeDictType
;
447
VTypeDictType
myVTypeDict
;
448
450
typedef
std::map< std::string, RandomDistributor<MSVehicleType*>* >
VTypeDistDictType
;
452
VTypeDistDictType
myVTypeDistDict
;
453
455
bool
myDefaultVTypeMayBeDeleted
;
456
458
std::map<const MSEdge* const, std::vector<SUMOVehicle*> >
myWaiting
;
459
461
unsigned
int
myWaitingForPerson
;
462
464
SUMOReal
myScale
;
465
466
private
:
468
MSVehicleControl
(
const
MSVehicleControl
& s);
469
471
MSVehicleControl
&
operator=
(
const
MSVehicleControl
& s);
472
473
474
};
475
476
477
#endif
478
479
/****************************************************************************/
480
build
buildd
sumo-0.17.1~dfsg
src
microsim
MSVehicleControl.h
Generated on Sun Jun 16 2013 17:30:17 for SUMO - Simulation of Urban MObility by
1.8.3.1