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-2013 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
61
62
// ===========================================================================
63
// class declarations
64
// ===========================================================================
65
class
MSEdge
;
66
class
MSEdgeControl
;
67
class
MSJunctionControl
;
68
class
MSInsertionControl
;
69
class
SUMORouteLoaderControl
;
70
class
MSPersonControl
;
71
class
MSVehicle
;
72
class
MSRoute
;
73
class
MSLane
;
74
class
MSTLLogicControl
;
75
class
MSDetectorControl
;
76
class
ShapeContainer
;
77
class
BinaryInputDevice
;
78
class
MSEdgeWeightsStorage
;
79
class
SUMOVehicle
;
80
81
82
// ===========================================================================
83
// class definitions
84
// ===========================================================================
89
class
MSNet
{
90
public
:
94
enum
SimulationState
{
96
SIMSTATE_RUNNING
,
98
SIMSTATE_END_STEP_REACHED
,
100
SIMSTATE_NO_FURTHER_VEHICLES
,
102
SIMSTATE_CONNECTION_CLOSED
,
104
SIMSTATE_ERROR_IN_SIM
,
106
SIMSTATE_TOO_MANY_VEHICLES
107
};
108
109
110
public
:
115
static
MSNet
*
getInstance
();
116
117
132
MSNet
(
MSVehicleControl
* vc,
MSEventControl
* beginOfTimestepEvents,
133
MSEventControl
* endOfTimestepEvents,
MSEventControl
* insertionEvents,
134
ShapeContainer
* shapeCont = 0);
135
136
138
virtual
~MSNet
();
139
140
152
void
closeBuilding
(
MSEdgeControl
* edges,
MSJunctionControl
* junctions,
153
SUMORouteLoaderControl
* routeLoaders,
MSTLLogicControl
* tlc,
154
std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles);
155
156
160
static
void
clearAll
();
161
162
170
int
simulate
(
SUMOTime
start,
SUMOTime
stop);
171
172
176
void
simulationStep
();
177
178
180
void
loadRoutes
();
181
182
190
void
closeSimulation
(
SUMOTime
start);
191
192
198
SimulationState
simulationState
(
SUMOTime
stopTime)
const
;
199
200
204
static
std::string
getStateMessage
(
SimulationState
state);
205
206
210
SUMOTime
getCurrentTimeStep
()
const
;
211
212
216
void
writeOutput
();
217
218
222
bool
logSimulationDuration
()
const
;
223
224
225
227
228
233
void
preSimStepOutput
()
const
;
234
235
240
void
postSimStepOutput
()
const
;
241
//}
242
243
244
247
253
MSVehicleControl
&
getVehicleControl
() {
254
return
*
myVehicleControl
;
255
}
256
257
266
virtual
MSPersonControl
&
getPersonControl
();
267
268
274
MSEdgeControl
&
getEdgeControl
() {
275
return
*
myEdges
;
276
}
277
278
284
MSInsertionControl
&
getInsertionControl
() {
285
return
*
myInserter
;
286
}
287
288
294
MSDetectorControl
&
getDetectorControl
() {
295
return
*
myDetectorControl
;
296
}
297
298
304
MSTLLogicControl
&
getTLSControl
() {
305
return
*
myLogics
;
306
}
307
308
314
MSJunctionControl
&
getJunctionControl
() {
315
return
*
myJunctions
;
316
}
317
318
324
MSEventControl
&
getBeginOfTimestepEvents
() {
325
return
*
myBeginOfTimestepEvents
;
326
}
327
328
334
MSEventControl
&
getEndOfTimestepEvents
() {
335
return
*
myEndOfTimestepEvents
;
336
}
337
338
344
MSEventControl
&
getInsertionEvents
() {
345
return
*
myInsertionEvents
;
346
}
347
348
354
ShapeContainer
&
getShapeContainer
() {
355
return
*
myShapeContainer
;
356
}
357
358
364
MSEdgeWeightsStorage
&
getWeightsStorage
();
366
367
368
371
383
bool
addBusStop
(
MSBusStop
* busStop);
384
385
390
MSBusStop
*
getBusStop
(
const
std::string&
id
)
const
;
391
392
398
std::string
getBusStopID
(
const
MSLane
* lane,
const
SUMOReal
pos)
const
;
400
401
402
405
407
enum
VehicleState
{
409
VEHICLE_STATE_BUILT
,
411
VEHICLE_STATE_DEPARTED
,
413
VEHICLE_STATE_STARTING_TELEPORT
,
415
VEHICLE_STATE_ENDING_TELEPORT
,
417
VEHICLE_STATE_ARRIVED
,
419
VEHICLE_STATE_NEWROUTE
,
421
VEHICLE_STATE_STARTING_PARKING
,
423
VEHICLE_STATE_ENDING_PARKING
,
425
VEHICLE_STATE_STARTING_STOP
,
427
VEHICLE_STATE_ENDING_STOP
428
};
429
430
434
class
VehicleStateListener
{
435
public
:
437
VehicleStateListener
() { }
438
440
virtual
~VehicleStateListener
() { }
441
446
virtual
void
vehicleStateChanged
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to) = 0;
447
448
};
449
450
454
void
addVehicleStateListener
(VehicleStateListener* listener);
455
456
460
void
removeVehicleStateListener
(VehicleStateListener* listener);
461
462
468
void
informVehicleStateListener
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to);
470
471
472
480
static
SUMOReal
getTravelTime
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
481
482
490
static
SUMOReal
getEffort
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
491
492
493
/* @brief get the router, initialize on first use
494
* @param[in] prohibited The vector of forbidden edges (optional)
495
*/
496
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterTT
(
497
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
498
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterEffort
(
499
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
500
501
505
const
NamedRTree
&
getLanesRTree
()
const
;
506
507
508
protected
:
510
static
MSNet
*
myInstance
;
511
513
SUMORouteLoaderControl
*
myRouteLoaders
;
514
516
SUMOTime
myStep
;
517
518
519
522
524
MSVehicleControl
*
myVehicleControl
;
526
MSPersonControl
*
myPersonControl
;
528
MSEdgeControl
*
myEdges
;
530
MSJunctionControl
*
myJunctions
;
532
MSTLLogicControl
*
myLogics
;
534
MSInsertionControl
*
myInserter
;
536
MSDetectorControl
*
myDetectorControl
;
538
MSEventControl
*
myBeginOfTimestepEvents
;
540
MSEventControl
*
myEndOfTimestepEvents
;
542
MSEventControl
*
myInsertionEvents
;
544
ShapeContainer
*
myShapeContainer
;
546
MSEdgeWeightsStorage
*
myEdgeWeights
;
548
549
550
553
555
bool
myLogExecutionTime
;
556
558
bool
myLogStepNumber
;
559
561
long
mySimStepBegin
,
mySimStepEnd
,
mySimStepDuration
;
562
564
long
mySimBeginMillis
;
565
567
SUMOLong
myVehiclesMoved
;
568
//}
569
570
571
574
576
std::vector<SUMOTime>
myStateDumpTimes
;
578
std::vector<std::string>
myStateDumpFiles
;
580
581
582
584
int
myTooManyVehicles
;
585
587
NamedObjectCont<MSBusStop*>
myBusStopDict
;
588
590
std::vector<VehicleStateListener*>
myVehicleStateListeners
;
591
592
593
/* @brief The router instance for routing by trigger and by traci
594
* @note MSDevice_Routing has its own instance since it uses a different weight function
595
* @note we provide one member for every switchable router type
596
* because the class structure makes it inconvenient to use a superclass*/
597
mutable
bool
myRouterTTInitialized
;
598
mutable
DijkstraRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTDijkstra
;
599
mutable
AStarRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTAStar
;
600
mutable
DijkstraRouterEffort_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterEffort
;
601
602
604
mutable
std::pair<bool, NamedRTree>
myLanesRTree
;
605
606
607
private
:
609
MSNet
(
const
MSNet
&);
610
612
MSNet
&
operator=
(
const
MSNet
&);
613
614
615
};
616
617
618
#endif
619
620
/****************************************************************************/
621
home
delphi
sumo
src
microsim
MSNet.h
Generated by
1.8.2