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
60
// ===========================================================================
61
// class declarations
62
// ===========================================================================
63
class
MSEdge
;
64
class
MSEdgeControl
;
65
class
MSJunctionControl
;
66
class
MSInsertionControl
;
67
class
SUMORouteLoaderControl
;
68
class
MSPersonControl
;
69
class
MSVehicle
;
70
class
MSRoute
;
71
class
MSLane
;
72
class
MSTLLogicControl
;
73
class
MSDetectorControl
;
74
class
ShapeContainer
;
75
class
BinaryInputDevice
;
76
class
MSEdgeWeightsStorage
;
77
class
SUMOVehicle
;
78
79
80
// ===========================================================================
81
// class definitions
82
// ===========================================================================
87
class
MSNet
{
88
public
:
92
enum
SimulationState
{
94
SIMSTATE_RUNNING
,
96
SIMSTATE_END_STEP_REACHED
,
98
SIMSTATE_NO_FURTHER_VEHICLES
,
100
SIMSTATE_CONNECTION_CLOSED
,
102
SIMSTATE_ERROR_IN_SIM
,
104
SIMSTATE_TOO_MANY_VEHICLES
105
};
106
107
108
public
:
113
static
MSNet
*
getInstance
();
114
115
130
MSNet
(
MSVehicleControl
* vc,
MSEventControl
* beginOfTimestepEvents,
131
MSEventControl
* endOfTimestepEvents,
MSEventControl
* insertionEvents,
132
ShapeContainer
* shapeCont = 0);
133
134
136
virtual
~MSNet
();
137
138
150
void
closeBuilding
(
MSEdgeControl
* edges,
MSJunctionControl
* junctions,
151
SUMORouteLoaderControl
* routeLoaders,
MSTLLogicControl
* tlc,
152
std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles);
153
154
158
static
void
clearAll
();
159
160
168
int
simulate
(
SUMOTime
start,
SUMOTime
stop);
169
170
174
void
simulationStep
();
175
177
void
loadRoutes
();
178
179
187
void
closeSimulation
(
SUMOTime
start);
188
189
195
SimulationState
simulationState
(
SUMOTime
stopTime)
const
;
196
197
201
static
std::string
getStateMessage
(
SimulationState
state);
202
203
207
SUMOTime
getCurrentTimeStep
()
const
;
208
209
213
void
writeOutput
();
214
215
219
bool
logSimulationDuration
()
const
;
220
221
223
224
229
void
preSimStepOutput
()
const
;
230
231
236
void
postSimStepOutput
()
const
;
237
//}
238
239
242
248
MSVehicleControl
&
getVehicleControl
() {
249
return
*
myVehicleControl
;
250
}
251
252
261
virtual
MSPersonControl
&
getPersonControl
();
262
263
269
MSEdgeControl
&
getEdgeControl
() {
270
return
*
myEdges
;
271
}
272
273
279
MSInsertionControl
&
getInsertionControl
() {
280
return
*
myInserter
;
281
}
282
283
289
MSDetectorControl
&
getDetectorControl
() {
290
return
*
myDetectorControl
;
291
}
292
293
299
MSTLLogicControl
&
getTLSControl
() {
300
return
*
myLogics
;
301
}
302
303
309
MSJunctionControl
&
getJunctionControl
() {
310
return
*
myJunctions
;
311
}
312
313
319
MSEventControl
&
getBeginOfTimestepEvents
() {
320
return
*
myBeginOfTimestepEvents
;
321
}
322
323
329
MSEventControl
&
getEndOfTimestepEvents
() {
330
return
*
myEndOfTimestepEvents
;
331
}
332
333
339
MSEventControl
&
getInsertionEvents
() {
340
return
*
myInsertionEvents
;
341
}
342
343
349
ShapeContainer
&
getShapeContainer
() {
350
return
*
myShapeContainer
;
351
}
352
353
359
MSEdgeWeightsStorage
&
getWeightsStorage
();
361
362
363
366
378
bool
addBusStop
(
MSBusStop
* busStop);
379
380
385
MSBusStop
*
getBusStop
(
const
std::string&
id
)
const
;
386
387
393
std::string
getBusStopID
(
const
MSLane
* lane,
const
SUMOReal
pos)
const
;
395
396
397
398
399
400
403
405
enum
VehicleState
{
407
VEHICLE_STATE_BUILT
,
409
VEHICLE_STATE_DEPARTED
,
411
VEHICLE_STATE_STARTING_TELEPORT
,
413
VEHICLE_STATE_ENDING_TELEPORT
,
415
VEHICLE_STATE_ARRIVED
,
417
VEHICLE_STATE_NEWROUTE
418
};
419
420
424
class
VehicleStateListener
{
425
public
:
427
VehicleStateListener
() { }
428
430
virtual
~VehicleStateListener
() { }
431
436
virtual
void
vehicleStateChanged
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to) = 0;
437
438
};
439
440
444
void
addVehicleStateListener
(VehicleStateListener* listener);
445
446
450
void
removeVehicleStateListener
(VehicleStateListener* listener);
451
452
458
void
informVehicleStateListener
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to);
460
461
469
static
SUMOReal
getTravelTime
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
470
471
479
static
SUMOReal
getEffort
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t);
480
481
482
/* @brief get the router, initialize on first use
483
* @param[in] prohibited The vector of forbidden edges (optional)
484
*/
485
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterTT
(
486
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
487
SUMOAbstractRouter<MSEdge, SUMOVehicle>
&
getRouterEffort
(
488
const
std::vector<MSEdge*>& prohibited = std::vector<MSEdge*>())
const
;
489
490
491
protected
:
493
static
MSNet
*
myInstance
;
494
496
SUMORouteLoaderControl
*
myRouteLoaders
;
497
499
SUMOTime
myStep
;
500
501
502
505
507
MSVehicleControl
*
myVehicleControl
;
509
MSPersonControl
*
myPersonControl
;
511
MSEdgeControl
*
myEdges
;
513
MSJunctionControl
*
myJunctions
;
515
MSTLLogicControl
*
myLogics
;
517
MSInsertionControl
*
myInserter
;
519
MSDetectorControl
*
myDetectorControl
;
521
MSEventControl
*
myBeginOfTimestepEvents
;
523
MSEventControl
*
myEndOfTimestepEvents
;
525
MSEventControl
*
myInsertionEvents
;
527
ShapeContainer
*
myShapeContainer
;
529
MSEdgeWeightsStorage
*
myEdgeWeights
;
531
532
533
536
538
bool
myLogExecutionTime
;
539
541
bool
myLogStepNumber
;
542
544
long
mySimStepBegin
,
mySimStepEnd
,
mySimStepDuration
;
545
547
long
mySimBeginMillis
;
548
550
SUMOLong
myVehiclesMoved
;
551
//}
552
553
554
557
559
std::vector<SUMOTime>
myStateDumpTimes
;
561
std::vector<std::string>
myStateDumpFiles
;
563
564
566
int
myTooManyVehicles
;
567
568
570
NamedObjectCont<MSBusStop*>
myBusStopDict
;
571
573
std::vector<VehicleStateListener*>
myVehicleStateListeners
;
574
575
576
/* @brief The router instance for routing by trigger and by traci
577
* @note MSDevice_Routing has its own instance since it uses a different weight function
578
* @note we provide one member for every switchable router type
579
* because the class structure makes it inconvenient to use a superclass*/
580
mutable
bool
myRouterTTInitialized
;
581
mutable
DijkstraRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTDijkstra
;
582
mutable
AStarRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterTTAStar
;
583
mutable
DijkstraRouterEffort_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>
>*
myRouterEffort
;
584
585
586
private
:
588
MSNet
(
const
MSNet
&);
589
591
MSNet
&
operator=
(
const
MSNet
&);
592
593
594
};
595
596
597
#endif
598
599
/****************************************************************************/
600
build
buildd
sumo-0.18~dfsg
src
microsim
MSNet.h
Generated on Wed Oct 23 2013 01:15:09 for SUMO - Simulation of Urban MObility by
1.8.4