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.sourceforge.net/
16
// Copyright (C) 2001-2012 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
56
// ===========================================================================
57
// class declarations
58
// ===========================================================================
59
class
MSEdge
;
60
class
MSEdgeControl
;
61
class
MSJunctionControl
;
62
class
MSInsertionControl
;
63
class
MSRouteLoaderControl
;
64
class
MSPersonControl
;
65
class
MSVehicle
;
66
class
MSRoute
;
67
class
MSLane
;
68
class
MSTLLogicControl
;
69
class
MSDetectorControl
;
70
class
ShapeContainer
;
71
class
BinaryInputDevice
;
72
class
MSRouteLoader
;
73
class
MSEdgeWeightsStorage
;
74
class
SUMOVehicle
;
75
#ifdef _MESSAGES
76
class
MSMessageEmitter;
77
#endif
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
MSRouteLoaderControl
* 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
176
184
void
closeSimulation
(
SUMOTime
start);
185
186
192
SimulationState
simulationState
(
SUMOTime
stopTime)
const
;
193
194
198
static
std::string
getStateMessage
(
SimulationState
state) ;
199
200
204
SUMOTime
getCurrentTimeStep
()
const
;
205
206
210
void
writeOutput
();
211
212
216
bool
logSimulationDuration
()
const
;
217
218
220
221
226
void
preSimStepOutput
()
const
;
227
228
233
void
postSimStepOutput
()
const
;
234
//}
235
236
237
238
#ifdef HAVE_MESOSIM
239
240
241
246
void
saveState(std::ostream& os) ;
247
248
253
unsigned
int
loadState(
BinaryInputDevice
& bis) ;
255
#endif
256
259
265
MSVehicleControl
&
getVehicleControl
() {
266
return
*
myVehicleControl
;
267
}
268
269
278
MSPersonControl
&
getPersonControl
() ;
279
280
286
MSEdgeControl
&
getEdgeControl
() {
287
return
*
myEdges
;
288
}
289
290
296
MSInsertionControl
&
getInsertionControl
() {
297
return
*
myInserter
;
298
}
299
300
306
MSDetectorControl
&
getDetectorControl
() {
307
return
*
myDetectorControl
;
308
}
309
310
316
MSTLLogicControl
&
getTLSControl
() {
317
return
*
myLogics
;
318
}
319
320
326
MSJunctionControl
&
getJunctionControl
() {
327
return
*
myJunctions
;
328
}
329
330
336
MSEventControl
&
getBeginOfTimestepEvents
() {
337
return
*
myBeginOfTimestepEvents
;
338
}
339
340
346
MSEventControl
&
getEndOfTimestepEvents
() {
347
return
*
myEndOfTimestepEvents
;
348
}
349
350
356
MSEventControl
&
getInsertionEvents
() {
357
return
*
myInsertionEvents
;
358
}
359
360
366
ShapeContainer
&
getShapeContainer
() {
367
return
*
myShapeContainer
;
368
}
369
370
376
MSEdgeWeightsStorage
&
getWeightsStorage
() ;
378
379
380
383
395
bool
addBusStop
(
MSBusStop
* busStop);
396
397
402
MSBusStop
*
getBusStop
(
const
std::string&
id
)
const
;
403
404
410
std::string
getBusStopID
(
const
MSLane
* lane,
const
SUMOReal
pos)
const
;
412
413
414
415
416
417
420
422
enum
VehicleState
{
424
VEHICLE_STATE_BUILT
,
426
VEHICLE_STATE_DEPARTED
,
428
VEHICLE_STATE_STARTING_TELEPORT
,
430
VEHICLE_STATE_ENDING_TELEPORT
,
432
VEHICLE_STATE_ARRIVED
,
434
VEHICLE_STATE_NEWROUTE
435
};
436
437
441
class
VehicleStateListener
{
442
public
:
444
VehicleStateListener
() { }
445
447
virtual
~VehicleStateListener
() { }
448
453
virtual
void
vehicleStateChanged
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to) = 0;
454
455
};
456
457
461
void
addVehicleStateListener
(VehicleStateListener* listener) ;
462
463
467
void
removeVehicleStateListener
(VehicleStateListener* listener) ;
468
469
475
void
informVehicleStateListener
(
const
SUMOVehicle
*
const
vehicle,
VehicleState
to) ;
477
478
488
class
EdgeWeightsProxi
{
489
public
:
494
EdgeWeightsProxi
(
const
MSEdgeWeightsStorage
& vehKnowledge,
495
const
MSEdgeWeightsStorage
& netKnowledge)
496
:
myVehicleKnowledge
(vehKnowledge),
myNetKnowledge
(netKnowledge) {}
497
498
500
~EdgeWeightsProxi
() {}
501
502
510
SUMOReal
getTravelTime
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t)
const
;
511
512
520
SUMOReal
getEffort
(
const
MSEdge
*
const
e,
const
SUMOVehicle
*
const
v,
SUMOReal
t)
const
;
521
522
private
:
523
EdgeWeightsProxi
&
operator=
(
const
EdgeWeightsProxi
&);
// just to avoid a compiler warning
524
525
private
:
527
const
MSEdgeWeightsStorage
&
myVehicleKnowledge
;
528
530
const
MSEdgeWeightsStorage
&
myNetKnowledge
;
531
532
};
533
534
535
#ifdef _MESSAGES
536
537
typedef
NamedObjectCont< MSMessageEmitter* >
MsgEmitterDict;
538
539
// TODO
546
MSMessageEmitter* getMsgEmitter(
const
std::string& whatemit);
547
552
void
createMsgEmitter(std::string&
id
,
553
std::string& file,
554
const
std::string& base,
555
std::string& whatemit,
556
bool
reverse,
557
bool
table,
558
bool
xy,
559
SUMOReal
step);
560
#endif
561
562
protected
:
564
static
MSNet
*
myInstance
;
565
567
MSRouteLoaderControl
*
myRouteLoaders
;
568
570
SUMOTime
myStep
;
571
572
573
576
578
MSVehicleControl
*
myVehicleControl
;
580
MSPersonControl
*
myPersonControl
;
582
MSEdgeControl
*
myEdges
;
584
MSJunctionControl
*
myJunctions
;
586
MSTLLogicControl
*
myLogics
;
588
MSInsertionControl
*
myInserter
;
590
MSDetectorControl
*
myDetectorControl
;
592
MSEventControl
*
myBeginOfTimestepEvents
;
594
MSEventControl
*
myEndOfTimestepEvents
;
596
MSEventControl
*
myInsertionEvents
;
598
ShapeContainer
*
myShapeContainer
;
600
MSEdgeWeightsStorage
*
myEdgeWeights
;
602
603
604
607
609
bool
myLogExecutionTime
;
610
612
bool
myLogStepNumber
;
613
615
long
mySimStepBegin
,
mySimStepEnd
,
mySimStepDuration
;
616
618
long
mySimBeginMillis
;
619
621
long
myVehiclesMoved
;
622
//}
623
624
625
628
630
std::vector<SUMOTime>
myStateDumpTimes
;
632
std::vector<std::string>
myStateDumpFiles
;
634
635
637
int
myTooManyVehicles
;
638
639
641
NamedObjectCont<MSBusStop*>
myBusStopDict
;
642
644
std::vector<VehicleStateListener*>
myVehicleStateListeners
;
645
646
647
#ifdef _MESSAGES
648
649
MsgEmitterDict myMsgEmitter;
650
652
std::vector<MSMessageEmitter*> msgEmitVec;
653
#endif
654
655
656
private
:
658
MSNet
(
const
MSNet
&);
659
661
MSNet
&
operator=
(
const
MSNet
&);
662
663
664
};
665
666
667
#endif
668
669
/****************************************************************************/
670
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
microsim
MSNet.h
Generated on Mon Mar 24 2014 09:53:11 for SUMO - Simulation of Urban MObility by
1.8.1.2