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
MSNet.h
Go to the documentation of this file.
1
/****************************************************************************/
13
// The simulated network and simulation perfomer
14
/****************************************************************************/
15
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
16
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
17
/****************************************************************************/
18
//
19
// This file is part of SUMO.
20
// SUMO is free software: you can redistribute it and/or modify
21
// it under the terms of the GNU General Public License as published by
22
// the Free Software Foundation, either version 3 of the License, or
23
// (at your option) any later version.
24
//
25
/****************************************************************************/
26
#ifndef MSNet_h
27
#define MSNet_h
28
29
30
// ===========================================================================
31
// included modules
32
// ===========================================================================
33
#ifdef _MSC_VER
34
#include <
windows_config.h
>
35
#else
36
#include <
config.h
>
37
#endif
38
39
#include <typeinfo>
40
#include <vector>
41
#include <map>
42
#include <string>
43
#include <fstream>
44
#include <iostream>
45
#include <cmath>
46
#include <iomanip>
47
#include "
MSVehicleControl.h
"
48
#include "
MSEventControl.h
"
49
#include <
utils/geom/Boundary.h
>
50
#include <
utils/geom/Position.h
>
51
#include <
utils/common/SUMOTime.h
>
52
#include <
microsim/trigger/MSBusStop.h
>
53
#include <
utils/common/UtilExceptions.h
>
54
#include <
utils/common/NamedObjectCont.h
>
55
#include <
utils/common/SUMOAbstractRouter.h
>
56
#include <
utils/common/DijkstraRouterTT.h
>
57
#include <
utils/common/DijkstraRouterEffort.h
>
58
#include <
utils/common/AStarRouter.h
>
59
#include <
utils/common/NamedRTree.h
>
60
#include <
utils/common/PedestrianRouter.h
>
61
62
63
// ===========================================================================
64
// class declarations
65
// ===========================================================================
66
class
MSEdge
;
67
class
MSJunction
;
68
class
MSEdgeControl
;
69
class
MSJunctionControl
;
70
class
MSInsertionControl
;
71
class
SUMORouteLoaderControl
;
72
class
MSPersonControl
;
73
class
MSVehicle
;
74
class
MSRoute
;
75
class
MSLane
;
76
class
MSTLLogicControl
;
77
class
MSDetectorControl
;
78
class
ShapeContainer
;
79
class
BinaryInputDevice
;
80
class
MSEdgeWeightsStorage
;
81
class
SUMOVehicle
;
82
83
84
// ===========================================================================
85
// class definitions
86
// ===========================================================================
91
class
MSNet
{
92
public
:
96
enum
SimulationState
{
98
SIMSTATE_RUNNING
,
100
SIMSTATE_END_STEP_REACHED
,
102
SIMSTATE_NO_FURTHER_VEHICLES
,
104
SIMSTATE_CONNECTION_CLOSED
,
106
SIMSTATE_ERROR_IN_SIM
,
108
SIMSTATE_TOO_MANY_VEHICLES
109
};
110
111
//typedef PedestrianRouterDijkstra<MSEdge, MSLane> MSPedestrianRouterDijkstra;
112
typedef
PedestrianRouterDijkstra<MSEdge, MSLane, MSJunction>
MSPedestrianRouterDijkstra
;
113
114
115
116
public
:
121
static
MSNet
*
getInstance
();
122
123
138
MSNet
(
MSVehicleControl
* vc,
MSEventControl
* beginOfTimestepEvents,
139
MSEventControl
* endOfTimestepEvents,
MSEventControl
* insertionEvents,
140
ShapeContainer
* shapeCont = 0);
141
142
144
virtual
~MSNet
();
145
146
158
void
closeBuilding
(
MSEdgeControl
* edges,
MSJunctionControl
* junctions,
159
SUMORouteLoaderControl
* routeLoaders,
MSTLLogicControl
* tlc,
160
std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles);
161
162
166
static
void
clearAll
();
167
168
176
int
simulate
(
SUMOTime
start,
SUMOTime
stop);
177
178
182
void
simulationStep
();
183
184
186
void
loadRoutes
();
187
188
196
void
closeSimulation
(
SUMOTime
start);
197
198
204
SimulationState
simulationState
(
SUMOTime
stopTime)
const
;
205
206
210
static
std::string
getStateMessage
(
SimulationState
state);
211
212
216
inline
SUMOTime
getCurrentTimeStep
()
const
{
217
return
myStep
;
218
}
219
220
224
inline
void
setCurrentTimeStep
(
const
SUMOTime
step) {
225
myStep
= step;
226
}
227
228
232
void
writeOutput
();
233
234
238
bool
logSimulationDuration
()
const
;
239
240
241
243
244
249
void
preSimStepOutput
()
const
;
250
251
256
void
postSimStepOutput
()
const
;
257
//}
258
259
260
263
269
MSVehicleControl
&
getVehicleControl
() {
270
return
*
myVehicleControl
;
271
}
272
273
282
virtual
MSPersonControl
&
getPersonControl
();
283
284
290
MSEdgeControl
&
getEdgeControl
() {
291
return
*
myEdges
;
292
}
293
294
300
MSInsertionControl
&
getInsertionControl
() {
301
return
*
myInserter
;
302
}
303
304
310
MSDetectorControl
&
getDetectorControl
() {
311
return
*
myDetectorControl
;
312
}
313
314
320
MSTLLogicControl
&
getTLSControl
() {
321
return
*
myLogics
;
322
}
323
324
330
MSJunctionControl
&
getJunctionControl
() {
331
return
*
myJunctions
;
332
}
333
334
340
MSEventControl
&
getBeginOfTimestepEvents
() {
341
return
*
myBeginOfTimestepEvents
;
342
}
343
344
350
MSEventControl
&
getEndOfTimestepEvents
() {
351
return
*
myEndOfTimestepEvents
;
352
}
353
354
360
MSEventControl
&
getInsertionEvents
() {
361
return
*
myInsertionEvents
;
362
}
363
364
370
ShapeContainer
&
getShapeContainer
() {
371
return
*
myShapeContainer
;
372
}
373
374
380
MSEdgeWeightsStorage
&
getWeightsStorage
();
382
383
384
387
399
bool
addBusStop
(
MSBusStop
* busStop);
400
401
406
MSBusStop
*
getBusStop
(
const
std::string&
id
)
const
;
407
408
414
std::string
getBusStopID
(
const
MSLane
* lane,
const
SUMOReal
pos)
const
;
416
417
418
421
423
enum
VehicleState
{
425
VEHICLE_STATE_BUILT
,
427
VEHICLE_STATE_DEPARTED
,
429
VEHICLE_STATE_STARTING_TELEPORT
,
431
VEHICLE_STATE_ENDING_TELEPORT
,
433
VEHICLE_STATE_ARRIVED
,
435
VEHICLE_STATE_NEWROUTE
,
437
VEHICLE_STATE_STARTING_PARKING
,
439
VEHICLE_STATE_ENDING_PARKING
,
441
VEHICLE_STATE_STARTING_STOP
,
443
VEHICLE_STATE_ENDING_STOP
444
};
445
446
450
class
VehicleStateListener
{
451
public
:
453
VehicleStateListener
() { }
454
456
virtual
~VehicleStateListener
() { }
457
462
virtual
void
vehicleStateChanged
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to) = 0;
463
464
};
465
466
470
void
addVehicleStateListener
(VehicleStateListener* listener);
471
472
476
void
removeVehicleStateListener
(VehicleStateListener* listener);
477
478
484
void
informVehicleStateListener
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to);
486
487
488
496
static
SUMOReal
getTravelTime
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
497
498
506
static
SUMOReal
getEffort
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
507
508
509
/* @brief get the router, initialize on first use
510
* @param[in] prohibited The vector of forbidden edges (optional)
511
*/
512
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterTT
(
513
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
514
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterEffort
(
515
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
516
MSPedestrianRouterDijkstra
&
getPedestrianRouter
(
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
517
518
522
const
NamedRTree
&
getLanesRTree
()
const
;
523
524
525
protected
:
527
static
MSNet
*
myInstance
;
528
530
SUMORouteLoaderControl
*
myRouteLoaders
;
531
533
SUMOTime
myStep
;
534
535
536
539
541
MSVehicleControl
*
myVehicleControl
;
543
MSPersonControl
*
myPersonControl
;
545
MSEdgeControl
*
myEdges
;
547
MSJunctionControl
*
myJunctions
;
549
MSTLLogicControl
*
myLogics
;
551
MSInsertionControl
*
myInserter
;
553
MSDetectorControl
*
myDetectorControl
;
555
MSEventControl
*
myBeginOfTimestepEvents
;
557
MSEventControl
*
myEndOfTimestepEvents
;
559
MSEventControl
*
myInsertionEvents
;
561
ShapeContainer
*
myShapeContainer
;
563
MSEdgeWeightsStorage
*
myEdgeWeights
;
565
566
567
570
572
bool
myLogExecutionTime
;
573
575
bool
myLogStepNumber
;
576
578
long
mySimStepBegin
,
mySimStepEnd
,
mySimStepDuration
;
579
581
long
mySimBeginMillis
;
582
584
SUMOLong
myVehiclesMoved
;
585
//}
586
587
588
591
593
std::vector<SUMOTime>
myStateDumpTimes
;
595
std::vector<std::string>
myStateDumpFiles
;
597
598
599
601
int
myTooManyVehicles
;
602
604
NamedObjectCont<MSBusStop*>
myBusStopDict
;
605
607
std::vector<VehicleStateListener*>
myVehicleStateListeners
;
608
609
610
/* @brief The router instance for routing by trigger and by traci
611
* @note MSDevice_Routing has its own instance since it uses a different weight function
612
* @note we provide one member for every switchable router type
613
* because the class structure makes it inconvenient to use a superclass*/
614
mutable
bool
myRouterTTInitialized
;
615
mutable
DijkstraRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTDijkstra
;
616
mutable
AStarRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTAStar
;
617
mutable
DijkstraRouterEffort_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterEffort
;
618
mutable
MSPedestrianRouterDijkstra
*
myPedestrianRouter
;
619
620
622
mutable
std::pair<bool, NamedRTree>
myLanesRTree
;
623
624
626
static
const
std::string
STAGE_EVENTS
;
627
static
const
std::string
STAGE_MOVEMENTS
;
628
static
const
std::string
STAGE_LANECHANGE
;
629
static
const
std::string
STAGE_INSERTIONS
;
630
631
private
:
633
MSNet
(
const
MSNet
&);
634
636
MSNet
&
operator=
(
const
MSNet
&);
637
638
639
};
640
641
642
#endif
643
644
/****************************************************************************/
645
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
MSNet.h
Generated on Thu Nov 20 2014 19:49:55 for SUMO - Simulation of Urban MObility by
1.8.1.2