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-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
371
void
saveState
(
OutputDevice
& out);
373
374
377
void
abortWaiting
();
378
379
380
public
:
382
static
MTRand
myVehicleParamsRNG
;
383
384
385
private
:
392
bool
checkVType
(
const
std::string&
id
);
393
394
protected
:
397
399
unsigned
int
myLoadedVehNo
;
400
402
unsigned
int
myRunningVehNo
;
403
405
unsigned
int
myEndedVehNo
;
406
408
unsigned
int
myDiscarded
;
409
411
unsigned
int
myCollisions
;
412
414
unsigned
int
myTeleports
;
416
417
420
422
SUMOReal
myTotalDepartureDelay
;
423
425
SUMOReal
myTotalTravelTime
;
427
428
431
433
typedef
std::map< std::string, SUMOVehicle* >
VehicleDictType
;
435
VehicleDictType
myVehicleDict
;
437
438
441
443
typedef
std::map< std::string, MSVehicleType* >
VTypeDictType
;
445
VTypeDictType
myVTypeDict
;
446
448
typedef
std::map< std::string, RandomDistributor<MSVehicleType*>* >
VTypeDistDictType
;
450
VTypeDistDictType
myVTypeDistDict
;
451
453
bool
myDefaultVTypeMayBeDeleted
;
454
456
std::map<const MSEdge* const, std::vector<SUMOVehicle*> >
myWaiting
;
457
459
unsigned
int
myWaitingForPerson
;
460
462
SUMOReal
myScale
;
463
464
private
:
466
MSVehicleControl
(
const
MSVehicleControl
& s);
467
469
MSVehicleControl
&
operator=
(
const
MSVehicleControl
& s);
470
471
472
};
473
474
475
#endif
476
477
/****************************************************************************/
478
build
buildd
sumo-0.18~dfsg
src
microsim
MSVehicleControl.h
Generated on Wed Oct 23 2013 01:15:10 for SUMO - Simulation of Urban MObility by
1.8.4