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
243
245
unsigned
int
getCollisionCount
()
const
{
246
return
myCollisions
;
247
}
248
249
251
unsigned
int
getTeleportCount
()
const
{
252
return
myTeleports
;
253
}
254
255
259
SUMOReal
getTotalDepartureDelay
()
const
{
260
return
myTotalDepartureDelay
;
261
}
262
263
267
SUMOReal
getTotalTravelTime
()
const
{
268
return
myTotalTravelTime
;
269
}
271
272
273
276
289
bool
addVType
(
MSVehicleType
* vehType);
290
291
305
bool
addVTypeDistribution
(
const
std::string&
id
,
RandomDistributor<MSVehicleType*>
* vehTypeDistribution);
306
307
315
bool
hasVTypeDistribution
(
const
std::string&
id
)
const
;
316
317
322
MSVehicleType
*
getVType
(
const
std::string&
id
= DEFAULT_VTYPE_ID);
323
324
328
void
insertVTypeIDs
(std::vector<std::string>& into)
const
;
330
331
void
addWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
332
333
void
removeWaiting
(
const
MSEdge
*
const
edge,
SUMOVehicle
* vehicle);
334
335
SUMOVehicle
*
getWaitingVehicle
(
const
MSEdge
*
const
edge,
const
std::set<std::string>& lines);
336
339
void
registerOneWaitingForPerson
() {
340
myWaitingForPerson
++;
341
}
342
345
void
unregisterOneWaitingForPerson
() {
346
myWaitingForPerson
--;
347
}
348
350
void
registerCollision
() {
351
myTeleports
++;
352
myCollisions
++;
353
}
354
356
void
registerTeleport
() {
357
myTeleports
++;
358
}
359
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
home
delphi
sumo
src
microsim
MSVehicleControl.h
Generated by
1.8.2