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
GUIVehicleControl.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// The class responsible for building and deletion of vehicles (gui-version)
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2014 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
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <
utils/foxtools/MFXMutex.h
>
34
#include "
GUIVehicleControl.h
"
35
#include "
GUIVehicle.h
"
36
#include "
GUINet.h
"
37
#include <
gui/GUIGlobals.h
>
38
39
#ifdef CHECK_MEMORY_LEAKS
40
#include <
foreign/nvwa/debug_new.h
>
41
#endif // CHECK_MEMORY_LEAKS
42
43
44
// ===========================================================================
45
// member method definitions
46
// ===========================================================================
47
GUIVehicleControl::GUIVehicleControl
()
48
:
MSVehicleControl
() {}
49
50
51
GUIVehicleControl::~GUIVehicleControl
() {
52
// just to quit cleanly on a failure
53
if
(
myLock
.
locked
()) {
54
myLock
.
unlock
();
55
}
56
}
57
58
59
SUMOVehicle
*
60
GUIVehicleControl::buildVehicle
(
SUMOVehicleParameter
* defs,
61
const
MSRoute
* route,
const
MSVehicleType
* type) {
62
myLoadedVehNo
++;
63
if
(
myMaxRandomDepartOffset
> 0) {
64
// round to the closest usable simulation step
65
defs->
depart
+=
DELTA_T
*
int
((
myVehicleParamsRNG
.
rand
((
int
)
myMaxRandomDepartOffset
) + 0.5 *
DELTA_T
) /
DELTA_T
);
66
}
67
MSVehicle
* built =
new
GUIVehicle
(defs, route, type, type->
computeChosenSpeedDeviation
(
myVehicleParamsRNG
));
68
MSNet::getInstance
()->
informVehicleStateListener
(built,
MSNet::VEHICLE_STATE_BUILT
);
69
return
built;
70
}
71
72
73
bool
74
GUIVehicleControl::addVehicle
(
const
std::string&
id
,
SUMOVehicle
* v) {
75
AbstractMutex::ScopedLocker
locker(
myLock
);
76
return
MSVehicleControl::addVehicle
(
id
, v);
77
}
78
79
80
void
81
GUIVehicleControl::deleteVehicle
(
SUMOVehicle
* veh,
bool
discard) {
82
AbstractMutex::ScopedLocker
locker(
myLock
);
83
MSVehicleControl::deleteVehicle
(veh, discard);
84
}
85
86
87
void
88
GUIVehicleControl::insertVehicleIDs
(std::vector<GUIGlID>& into) {
89
AbstractMutex::ScopedLocker
locker(
myLock
);
90
into.reserve(
myVehicleDict
.size());
91
for
(VehicleDictType::iterator i =
myVehicleDict
.begin(); i !=
myVehicleDict
.end(); ++i) {
92
SUMOVehicle
* veh = (*i).second;
93
if
(veh->
isOnRoad
()) {
94
into.push_back(static_cast<GUIVehicle*>((*i).second)->getGlID());
95
}
96
}
97
}
98
99
100
void
101
GUIVehicleControl::secureVehicles
() {
102
myLock
.
lock
();
103
}
104
105
106
void
107
GUIVehicleControl::releaseVehicles
() {
108
myLock
.
unlock
();
109
}
110
111
112
113
/****************************************************************************/
114
tmp
buildd
sumo-0.21.0+dfsg
src
guisim
GUIVehicleControl.cpp
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2